IonicWind Software

IWBasic => General Questions => Topic started by: Andy on November 04, 2017, 06:10:46 AM

Title: Quickest way to empty an array
Post by: Andy on November 04, 2017, 06:10:46 AM
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.


Title: Re: Quickest way to empty an array
Post by: Brian on November 04, 2017, 06:54:40 AM
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?

Title: Re: Quickest way to empty an array
Post by: Andy on November 04, 2017, 07:45:30 AM
Brian,

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

Cheers,
Andy.
Title: Re: Quickest way to empty an array
Post by: LarryMc on November 04, 2017, 10:03:28 AM
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.
Title: Re: Quickest way to empty an array
Post by: aurelCB on November 18, 2017, 10:43:28 AM
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... ::)
Title: Re: Quickest way to empty an array
Post by: Andy on November 18, 2017, 11:35:50 PM
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.