In a message dated 5/12/2004 5:10:26 PM Pacific Daylight Time, 
[EMAIL PROTECTED] writes:


> Is it not possible to store a file handle in a dynamic array?
> 
> This seems to work:
> 
> DIM FILE.HANDLES(10)
> OPEN '','PARTS' TO FILE.HANDLES(1) ELSE PRINT 'noopen'
> READ THIS.REC FROM FILE.HANDLES(1), '1900-90' ELSE PRINT 'noread'
> 
> ...but I'd rather use dynamic arrays.

The reason you cannot is because of the way the variables are stored in the 
run engine (work space).
A dynamic array has no fixed ending, each element ends when the parser 
encounters an attribute mark or end-of-string mark.
Thus the dynamic array "DOG":CHAR(254):"CAT":CHAR(255) ends cell one at 
position 4 and cell two ends at position 8.

However in a dimensioned array the endings are pre-determined.  Each 
dimensioned array cell has eight bytes, so a parser does not need to scan the cell to 
see where it ends.

Since file pointers may contain any valid bytes, they can contain FF or FE as 
valid bytes.  In a dynamic array this says "new cell" or "end of array".  
Thus they would royally screw up the dynamic array if they were allowed to be 
stored in it.  In fact you can create new cells in a dynamic array by inserting 
this bytes into the middle of it.  So starting with an array like
A = "DOG":CHAR(254):"CAT"
A = INSERT(A,2;"FROG":CHAR(254):"FISH")
would generate a new array
"DOG":CHAR(254):"FROG":CHAR(254):"FISH":CHAR(254):"CAT"
thus a single insert takes a 2 cell dynamic array and makes it a four cell 
one.

The long and the short is, any data that could possibly contain dynamic-a
rray-delimiters should not be stored in dynamic arrays, unless you are willing to 
face the consequences of that action.  For file pointers, this restriction was 
imposed for you, you can't override it (at least not easily).  For other 
types of data, you have to impose it yourself.

Will Johnson
Fast Forward Technologies
-------
u2-users mailing list
[EMAIL PROTECTED]
http://www.u2ug.org/listinfo/u2-users

Reply via email to