IonicWind Software

IWBasic => General Questions => Topic started by: srod on April 25, 2007, 02:57:36 PM

Title: ISTRINGs
Post by: srod on April 25, 2007, 02:57:36 PM
Hi,

just taking a good look at EMBasic and have a question (well 2 actually!  :)) regarding ISTRINGs.

If I define an ISTRING variable of say 3000 characters, then does the compiler allocate 3000 bytes of memory regardless, even if, say, I only ever place a single character within the underlying variable?

Question 2; how do you create an array of ISTRING variables?  Nearest I can figure is that I need to define a UDT containing an ISTRING field and then define an array of such types.  I must be missing something here!

Thanks in advance.
Title: Re: ISTRINGs
Post by: mrainey on April 25, 2007, 06:12:56 PM
I believe the answer to your first question is yes.


Here's how I define and access arrays of IStrings:

define one-dimensional array - 100 IStrings of ten characters max length (including a null character)
Def SingleArray[10,100]:IString


When referencing elements from the array, always use 0 as the first parameter:

assign text to sixth string
SingleArray[0,5]="Hello"



define two-dimensional array - 25 indexes of 10 IStrings of eight characters max length (including a null character)
Def MultiArray[8,25,10]:IString

assign text to eighth string of thirteenth index
MultiArray[0,12,7]="Goodbye"
Title: Re: ISTRINGs
Post by: srod on April 26, 2007, 03:12:04 AM
Interesting.  The way you've defined an array of istrings there makes sense.

Thanks.