[futurebasic] re: [FB] Dynamic true record creation

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : December 2000 : Group Archive : Group : All Groups

From: Jay Reeve <jktr@...>
Date: Mon, 18 Dec 00 11:21:14 -0600
Hi Anders,

I appologize for my unhelpfully-erroneous posts yesterday. If I 
understood your question, you are looking for dynamic (XREF@) arrays of 
true records. In spite of the difficulties I had in putting together an 
example in two minutes yesterday, these work very well and are very easy 
to use. I use them in almost everything I do.

Were you able to get something working? I will be very happy to offer any 
help (more accurate, I hope!) I can, if it still doesn't make sense. Here 
is a cleaned-up, tested and working version of what I sent yesterday:

begin record myRecordType'Define record structure
dim aString$
dim aLong&
dim anInt%
end record
dim recsAvail

xref@ myRecordArray(_maxInt) as myRecordType'Create array structure

recsAvail = 2'This can be set to whatever value you need

'Allocate memory
myRecordArray = fn newHandle(recsAvail*sizeof(myRecordType))
if myRecordArray = 0 then stop'Error routine goes here!

myRecordArray.aString(1) = "This is how you access record fields."
print myRecordArray.aString(1)'Access field from record

'Change memory allocation dynamically:
recsAvail = 10
call sethandlesize(myRecordArray,recsAvail*sizeof(myRecordType))
if syserror then stop'Error routine goes here!

myRecordArray(9) = myRecordArray(1)'Copy record
print myRecordArray.aString(9)'Access field from copy

'Output:
'This is how you access record fields.
'This is how you access record fields.