G'day all,
Jonathan wrote:
I define a record...
DIM RECORD testRec
DIM testFirstEntry%
DIM testSecondEntry&
DIM 25 testThirdEntry$
DIM END RECORD.testRec
Then I use ( 3*_testRec + _testThirdEntry) type constructions
the put and get the info in the handle. This seems as intuitive
as I need. I'm not saying XREFs is not good, just that they
seem to create confusion (would they be a hangover from a
time when there was no support for handles and pointers in FB?)
and thus I have never perceived that the gain I could obtain
from using them would exceed the investment in time and grey
matter to grok and debug the little thingies (This is of course
a reflection on the bad quality of my grey matter, not on XREF,
but my point was that if others have similar 'conceptual' problems
with XREF, there are other techniques...)
When set up it is much easier to access record arrays than you are
doing, just set as shown below:
_maxRecs = 100 'just for demo, can be any amount.
DIM gtestRecH& 'setup the handle for the array of records
XREF@ gtestRecH.testRec(_maxRecs*_testRec) 'can be any value, I usually
'setup just one record,
then add other records
'as needed with
SETHANDLESIZE.
'setup fake data for demo purposes
FOR d% = 0 to _maxRecs-1
gtestRecH.testFirstEntry%(d%) = d%
gtestRecH.testSecondEntry& = d%
gtestRecH.testThirdEntry$ = LEFT$(STR$(d%),24))
NEXT
Just use similar methods to access the array data. I also keep a track
of how many data elements I have
& what I am operating at the moment. Makes for easy display of a data
record, anywhere in the array.
To increase(/decrease) the array just use the following method:
maxRec& = maxRec&+1 'increase num of records
currRec& = maxRec& 'set pointer records to newest
bytes& = maxRec&*_testRec 'set new amont of bytes for array of records
oserr% = FM SETHANDLESIZE(gtestRecH&, bytes&)
I hope this help your understanding of XREF@
Regards,
Chris Wyatt, in Bendigo, Victoria, Australia.