IonicWind Software

IWBasic => General Questions => Topic started by: Andy on April 04, 2012, 05:50:31 AM

Title: Initialize a string
Post by: Andy on April 04, 2012, 05:50:31 AM
Hi,

From difficult question to probably a simple one:

How to initialize a string

The string is defined at the TOP of the program

DEF mystring[1000]:string

The string is populated with a 1000 entries.

Is there a way to 'empty' mystring (up to a 1000 entries) without doing a

For x = 1 to 1000
mystring[ x ] = ""
Next loop  ?

Thanks,
Andy.


Title: Re: Initialize a string
Post by: Brian on April 04, 2012, 07:32:55 AM
STRINGNAME[0] = NULL ?

Brian
Title: Re: Initialize a string
Post by: Andy on April 04, 2012, 08:09:58 AM
Thanks Brian

Will try that, did you get Avast sorted?

Andy.

Title: Re: Initialize a string
Post by: LarryMc on April 04, 2012, 09:23:04 AM
the easiest is stringname="" if you are using the string in the conventional way.

If you are using it as a buffer and manipulating  it with pointers you can use the API rtlzeromemory(mystring,len(mystring)) which is what I use all the time to make sure UDT's are zeroed out.

LarryMc
Title: Re: Initialize a string
Post by: Brian on April 04, 2012, 12:03:55 PM
Andy,

I just knew Clever Knickers McCaughn would have a better answer than me !

But that's OK - we all learn something new every day

And, yes, I did get Avast sorted, thanks very much - it was as you pointed out

Brian
Title: Re: Initialize a string
Post by: LarryMc on April 04, 2012, 03:36:13 PM
Quote from: Brian Pugh on April 04, 2012, 12:03:55 PM
... we all learn something new every day...
Including me.  But in my case it it usually something I learned and forgot from the day before. :o

LarryMc
Title: Re: Initialize a string
Post by: Andy on April 05, 2012, 04:10:46 AM
Now now ladies!  :)  :)

Larry, your first option worked - Thanks!

Any chance you could have a look at my other problem?
Entry point _ftol2 not located, but it's okay if your very busy.

The function isn't included in the MSVCRT.dll for Windows XP but is for Win 7 and Vista.

Could really do with finding a solution to this, I have a work around but it's not as good.

Thanks,
Andy.