XREF - Records - resent (ignore if seen )
Quote from Forum Archives on November 11, 1997, 8:06 pmPosted by: David.Cottrell <David.Cottrell@...>
I may have solved my XREF problem - but I'm worried that my solution does
not accord with what I have read regarding XREF and arrays of records.The XREF@#1 example that came with FB mentions that the one must use the
array.Top& workaround to get the base of the array. I don't do this. I do
this (borrowed from Ross) in defining the globals.DIM RECORD MyRec
DIM MYmean!
DIM 63 MYString$
DIM END RECORD .MyRecDIM gList&
XREF @ gList.MyRec(1000)
END GLOBALS
Next, I've read in a number of examples that one should work on a copy of
the handle in a local FN. I don't do this. I do this:LOCAL FN enterData (noPoints%)
size& = (noPoints% * _MyRec) 'eg. size - resizing works OK
gList& = FN GrowArray (gList&,size&) 'from FB egs XREF@ #2.BASFOR x = 0 TO 2
gList.MYmean!(x) = x + 0.001
gList.MYString$(x) = "the String"
NEXT x
END FNAll this seems to work - but how stable is it? I fear that it might be
leaving a memory mess around since I have seen it fail (once) not on
calling FN enterData, but on a subsequent menu operation.Anyone know the secret here? The example I'm working from is Ross's from
IB, but the array.Top& thing worries me.Cheers
David
------------------------------------------------------------------
Dr David Cottrell James Cook UniversityAll unconventional spellings that you might notice in the above are
intentional, and are just part of a living dynamic language.
------------------------------------------------------------------
Posted by: David.Cottrell <David.Cottrell@...>
not accord with what I have read regarding XREF and arrays of records.
The XREF@#1 example that came with FB mentions that the one must use the
array.Top& workaround to get the base of the array. I don't do this. I do
this (borrowed from Ross) in defining the globals.
DIM RECORD MyRec
DIM MYmean!
DIM 63 MYString$
DIM END RECORD .MyRec
DIM gList&
XREF @ gList.MyRec(1000)
END GLOBALS
Next, I've read in a number of examples that one should work on a copy of
the handle in a local FN. I don't do this. I do this:
LOCAL FN enterData (noPoints%)
size& = (noPoints% * _MyRec) 'eg. size - resizing works OK
gList& = FN GrowArray (gList&,size&) 'from FB egs XREF@ #2.BAS
FOR x = 0 TO 2
gList.MYmean!(x) = x + 0.001
gList.MYString$(x) = "the String"
NEXT x
END FN
All this seems to work - but how stable is it? I fear that it might be
leaving a memory mess around since I have seen it fail (once) not on
calling FN enterData, but on a subsequent menu operation.
Anyone know the secret here? The example I'm working from is Ross's from
IB, but the array.Top& thing worries me.
Cheers
David
------------------------------------------------------------------
Dr David Cottrell James Cook University
All unconventional spellings that you might notice in the above are
intentional, and are just part of a living dynamic language.
------------------------------------------------------------------