Main Board > Wish List

Short-hand syntax for anonymous arrays or objects initialization

<< < (3/3)

RobL:
Hi James,

I get the same result as you do, but here's something interesting.

The following code doesn't work:

--- Code: ---begin
!
dim Fld$[*]
read data from "Mike,Was,Here",sep="," to Fld${all}
print Fld$[1]," / ",Fld$[2]," / ",Fld$[3]
-:end
-:run
Mike /  /
-:

--- End code ---

But, with the addition of a line that prints the array elements, it does.

--- Code: ---begin
!
dim Fld$[*]
print Fld$[1],Fld$[2],Fld$[3]
read data from "Mike,Was,Here",sep="," to Fld${all}
print Fld$[1]," / ",Fld$[2]," / ",Fld$[3]
-:end
-:run

Mike / Was / Here
-:

--- End code ---

I'm not sure why printing these elements is causing them to be created in the array, but that seems to be what's happening.

Consider the following:

--- Code: ---begin
dim Fld$[*]
for z=1 to 3
print Fld$[z]
print dim(read num(Fld$))
next
-:end
-:run

 1

 2

 3
-:

--- End code ---

Regards,

Rob Leighton

Mike King:
Yes -- referencing the next element to be create in a dynamic array will cause it to be created.

Navigation

[0] Message Index

[*] Previous page

Go to full version