[futurebasic] Re: [FB] Re : [FB] Array Bounds

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : June 1999 : Group Archive : Group : All Groups

From: GBeckman@...
Date: Sun, 6 Jun 1999 23:42:22 EDT
In a message dated 6/7/99 1:50:35 AM, aboyd@... writes:

>DIM myName$(6)    'create 6-elements
>
>
>Has something changed?
>or
>Is this a misprint?
>or
>Is Rick be confused?

I hope that Rick is not confused, as I am using the equivalent of the 7th 
element (0) in many many routines.    The preferences will let you eliminate 
the 0 element if you like.  This bit me on a port to Borland's Delphi, as in 
the Mac verison the 0 element was being used and I in old fashioned Pascal 
style created my arrays [1..6] and had to go back and make that [0..6].   

	As long as we are on the subject, remember that strings are similar 
(an array of characters), the first element being the length byte... so a 
string is always one byte longer than the declaration.  If this ends up being 
an uneven number, then you must add another byte when figuring the memory you 
are using.  (Don't ask me why Mac requires this starting on an even memory 
location for storage, but it does)

So..dim  16 myname$(6) creates 7 elements of 18  or 126 bytes if you want to 
say use:

WRITE FILE #1, @myName$(0),126 

to stuff the thing onto a disk.

that is 16+ 1 length +1 to even it out * 7 elements   (0 through 6)

You can fill them with 

for counter=0 to 6 myName$(counter)="test "+STR$(counter)  'didn't test that 
syntax

and will not go out of bounds.

Hope this helps,

George