May 26, 2024, 12:35:29 PM

News:

Own IWBasic 2.x ? -----> Get your free upgrade to 3.x now.........


Defining ISTRINGS

Started by LarryMc, May 13, 2008, 05:59:31 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

LarryMc

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
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

Ionic Wind Support Team

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.

Ionic Wind Support Team