April 20, 2024, 07:03:21 AM

News:

IonicWind Snippit Manager 2.xx Released!  Install it on a memory stick and take it with you!  With or without IWBasic!


Quickest way to empty an array

Started by Andy, November 04, 2017, 06:10:46 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Andy

Does anyone know the quickest way to empty an array.

This is the array called Vnamei.

istring Vnamei[800,20000] - room for 800 characters, and 20,000 entries.

I've been told that something like Vnamei = "", now I'm either doing something wrong or that's incorrect.

So at the moment I'm doing:

FOR x = 0 TO 1000
Vnamei[0,x]  = ""
NEXT x


which works, but takes up time.

Does anyone have ideas on this?

Thanks,
Andy.


Day after day, day after day, we struck nor breath nor motion, as idle as a painted ship upon a painted ocean.

Brian

November 04, 2017, 06:54:40 AM #1 Last Edit: November 04, 2017, 07:27:54 AM by Brian Pugh
Vnamei[0]=NULL - Does that work?

Brian

Edit: Andy, you asked Larry McC two years ago about this. Just found the answer, I think:

ISTRING buf[8]
rtlzeromemory(buf,LEN(buf))

Is this what you are after?


Andy

Brian,

Thanks for that, knew I'd been here before, yes that's the one I think.

Cheers,
Andy.
Day after day, day after day, we struck nor breath nor motion, as idle as a painted ship upon a painted ocean.

LarryMc

I was just getting ready to post that Brian.

Also, I believe if you can write your program in such a way as to use the New command it MAY zero out memory, but not sure.
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

aurelCB

Hmm
this one is interesting ,i do something like that in the past but i forget how .
Maybe i use CHAR then FreeMem i am not sure... ::)

Andy

Aurel,

Brian asked pretty much the same question just recently, If it's an array and just for normal every day use i.e. not sensitive data then pointers are far the quickest.

Create a pointer, use it, delete it, and the re-create it again for later use.

See the timings at the end of this thread:
http://www.ionicwind.com/forums/index.php?topic=6120.25

Andy.
Day after day, day after day, we struck nor breath nor motion, as idle as a painted ship upon a painted ocean.