IonicWind Software

IWBasic => General Questions => Topic started by: LarryMc on May 13, 2008, 05:59:31 PM

Title: Defining ISTRINGS
Post by: LarryMc on May 13, 2008, 05:59:31 PM
This might be covered somewhere but I couldn't find it in the help.

We normally define ISTRINGS like:
def a[300] as istring
def a[300]:istring
istring a[300]

I was working with a UDT and entered this as an element:
def a as istring
I would always put a dimension on an istring but this is a case where I forgot.

It compiled without any problem and my program didn't crash.
But I never assigned a value with greater than 50 characters.

Is it safe to assume that an istring def without a size will automatically default to 255 like a regular string?

my primary concern is writing a UDT to a bfile and knowing how big a record is if I decide to use get and put.


Larry
Title: Re: Defining ISTRINGS
Post by: Ionic Wind Support Team on May 13, 2008, 10:09:47 PM
No.   You're overwriting memory your process doesn't own. 

def a as istring

Defines a string that is 0 bytes long, or just an address.  If you had another element in the UDT like:

def a as istring
def b as DOUBLE

Then writing to a will overwrite the contents of b.  The reason the compiler allows it is there are some UDT's used by Windows that require a 0 sized reference for the last element of the structure.

Paul.