[futurebasic] Re: Records and arrays

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : July 1998 : Group Archive : Group : All Groups

From: Jay Reeve <jktr@...>
Date: Sun, 12 Jul 98 01:41:22 +0100
>1.	If I make these globals, how can I make the points& variable be a pointer
>to the TrianglePoints array or SquarePoints array or any other array I might
>make sometime?
shape.points& = @TrianglePoints(0)

>2. If "1" is too hard, how do I make an array of 10 vertex records in the
>shape record? 
I think the easiest way would be to put a handle in the vertex record, 
then use XREF@ to reference it as an array. See my XREF@ arrays demo on 
the webring, or write me and I'll try to find a copy to send you--it 
addresses almost exactly this situation.

>3.	Also, how do I pass the name of a record to a function?
You don't, unless you mean passing a string containing the name. 

To pass a record, all you need is the address. Inside the function, you 
can either use the same name you used where it was created, or another 
name:

DIM RECORD myRecord           'Define record structure
 DIM data1
 DIM data2
 DIM data3
 DIM data4
DIM END RECORD .myRecordSize

LOCAL FN useRecord(rec2use&)  'get address of record
 PRINT rec2use.data1          'do something with it;
 PRINT rec2use.data2          'this is the data from 
 PRINT rec2use.data3          'the calling function
 PRINT rec2use.data4          'below.
END FN

LOCAL FN createRecord
 DIM rec2send.myRecordSize    'create record var
 rec2send.data1 = 1           'put some data in it
 rec2send.data2 = 2
 rec2send.data3 = 3
 rec2send.data4 = 4

 FN useRecord(@rec2send)      'pass its address to other fn

END FN

FN createRecord

If this still isn't clear, let me know and I can help further.

 0"0
 =J= a  y
  "