[futurebasic] Re: [FB] Fortran and C to FB

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : May 1999 : Group Archive : Group : All Groups

From: Charlie Dickman <charlied@...>
Date: Fri, 21 May 1999 21:26:55 -0400
>How do the above relate to the below that were also in that post, seems I
>am missing a pxyz and v array(s), or am I? What are the below statements
>doing exactly with regards to the above?
>"*" has something to do with setting a pointer, correct? But to what, and
>to how many? :) C is so concise, which is great I think, but it can be hard
>to follow when porting to FB.
>XYZ *pxyz;  'this the same as accessing record XYZ?
>TRIANGLE *v; 'this just allocating a list of Triangle records of number v?
>long *ntri;  'this looks like a DIM and a pointer all in one.

These are variable declarations. "*" means "pointer to" so

XYZ *pxyz means "pxyz is a pointer to a XYZ"
TRIANGLE *v means "v is a pointer to a "TRIANGLE"
long *ntri means "ntri is a pointer to a long"

long is a basic C type (a long integer like & in FB) and it is a convention
that derived types are written in all caps to clue the human reader into
finding its definition somewhere in (probably) a .h file somewhere.

Pointers in FB are usually & types like TRIANGLE&. They contain an address
and can be used to reference elements of structures like TRIANGLE&.p1&. FB
uses offsets to calculate what is meant by TRIANGLE&.p1& which translates
roughly to [triangle&]+_p1&. This is just skimming the surface of using
pointers and handles (which are pointers to pointers) which are some of the
hardest things for novice programmers to understand.

Charlie Dickman