March 28, 2024, 05:54:47 AM

News:

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


ISTRINGs

Started by srod, April 25, 2007, 02:57:36 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

srod

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.

mrainey

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"
Software For Metalworking
http://closetolerancesoftware.com

srod

Interesting.  The way you've defined an array of istrings there makes sense.

Thanks.