IonicWind Software

IWBasic => General Questions => Topic started by: Ficko on January 29, 2007, 09:08:04 AM

Title: Some peculiarity with Istring
Post by: Ficko on January 29, 2007, 09:08:04 AM
I have a little bit hard time with Istring.

There is my code:

OPENCONSOLE
DEF Text[10,512] AS Istring

FOR A=0 TO 9
   Text[A] = STRING$(511,"H")
   PRINT LEN(Text[A])
   Func(Text[A])
NEXT A

DO:UNTIL INKEY$<>""
END

SUB Func(Ftext AS String)
   DEF MyString[512] AS IString
   MyString = Ftext
   Print Len(MyString)
ENDSUB

The â€Ã...“SUB Funcâ€Ã, won’t compile with Istring so I tried to use String instead.
It works but I am worried that I kind of  â€Ã...“over-stretchingâ€Ã, the String so I put it immediately into another Istring variable to work with.

Could it cause a memory overwrite despite that? ???

Csaba
Title: Re: Some peculiarity with Istring
Post by: Ionic Wind Support Team on January 29, 2007, 09:17:05 AM
ISTRING is a keyword, not a type.  You are doing it correctly now. The ISTRING keyword just lets you dimension a string to something besides the stock 255 characters.

Strings are passed by reference so the length of a string as a parameter is equal to the length that is passed.  In otherwords you are referencing the string that is passed to the function, not a separate copy.

Paul.
Title: Re: Some peculiarity with Istring
Post by: Ficko on January 29, 2007, 09:28:26 AM
Ok, that makes sence!

Thank You Paul