[futurebasic] Re: [FB] Records, "True" or "Pseudo"

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : August 2001 : Group Archive : Group : All Groups

From: Richard Goodman <bhomme@...>
Date: Thu, 16 Aug 2001 07:45:28 -0700
Thanks to both Jonathon (and by implication, Alain) and Jay for replying to
my question about records.

I am ignorant enough about records that I don't really understand
Jonathon's post. However, I will study the Reference Manual and Jonathon's
answer and see if I can put it all together. On the advice of you both, as
well as from Chris Wyatt who emailed be off list, I will attempt to use
true records.

Jay, I understand the value of dynamic arrays, but I don't know how to
construct them. Is this where XREF is used? I've never done any of this
sophisticated stuff, but I hope I can learn how. With a dynamic array of
records, I could have a record for each measure of a tune and have the user
input the desired number of measures. A dynamic array would then be
allocated with the user's chosen number of measures. Each record of a
measure would contain smaller records of its notes, and each note record
would contain fields for duration and tone, with a null tone representing a
rest. Does this make sense?

Richard
------------------------------------------
Jonathon wrote:

>
>no. at first i didn't understand either and saw them as the same thing under
>different wigs. alain pushed me to persist and i don't regret it...
>
>of course, 'real' records aren't limited in size, but the greatest adavntage
>is 'typing' a variable to another, or ever of the same type, and as a
>consequence of this, no collision in offset names.
>
>i explain, when you declare
>
>begin record toto
> dim titi  as handle
> dim tata  as handle
> dim tutu  as int
>end record
>
>you then have to create your variable so:
> dim myToto as handle to toto
>then means that you can refer to myToto..titi
>[remember to create the space for your variable, in this case
> fn newclearhandle( sizeof( toto))
>]
>
>if you try to use _titi, unlike with a 'pseudo' record, the compiler will
>choke. if you don't type your variable to 'toto', again the compiler will
>choke and cry at you. this is an advantage, believe me, it forces you to
>know what you're doing with what.
>now suppose that you have another record.
>
>begin record soso
> dim sisi  as handle
> dim sasa  as handle
> dim susu  as int
>end record
>
>you can 'type' toto to soso, and vice versa... see below:
>
>clear local
>local fn doSomething( theToto as handle to soso)
> ...
>end fn
>
>fn doSomething( myToto)
>
>of course, this is possible with 'pseudo' records... but at your own risk.
>here the compiler is on your side, will allow you to use
>sisi,sasa,susu,titi,tata,tutu as constants elsewhere if needs be.
>
>i also find that real records make for much cleaner displays in the
>debugger, but that says more about my [bad] coding.
>
>try real records, consider them like the psuedo records, and as time goes by
>the advatages will grow on you.
>
>:-j
>
>thanks to alain for insisting.
>

Jay wrote:

>
>I don't have a lot to add to Jonathan's description, except to second his
>advice to make the switch to true records. You might find you want more
>than one type of record to represent a note, each of which might have a
>field for duration or tone. With true records, you can create both, using
>the same field names if you wish. There's nothing inherently wrong with
>pseudo records, but for all the reasons Jonathan listed and more, true
>records are "better."
>
>Let me also add that IMHO, you will definitely want to use dynamic arrays
>for these records. They should be pretty straight forward, but let me
>know if you run into any difficulties. I can even show you how to swap
>"tunes" in your array instantly, by just changing handles.
>
>For unknown reasons, I have always kept my music separate from my
>computer interests, but I am somewhat knowledgeable in both fields and
>will be happy to help if you have questions or just need to bounce some
>ideas. It sounds like a fun project.
>
> 0"0
> =J= a  y