[comp.sys.mac.hypercard] Using a card name/id in a variable

cander@unisoft.UUCP (Charles Anderson) (05/30/90)

I'm working on a heterogeneous stack with about half a dozen different
backrounds. I have a couple of handlers and functions that store card
names/ids in local variables and then extract fields from the specified
card.  This seems to work so long as the current card is of the same
backround type as the card in the local variable.  When the backround
type is different, I get error messages about unknown field in
backround type <current card's backround>.

I played around with stuff in the message box and found that the
problem has something to do with having the card id in a variable.  The
following is a example of the problem:

    put field "foo" of card id 1234    -- works

    put "card id 1234" into bar
    put field "foo" of bar   -- fails

If I go to the card everything works fine, so I have written a function
that looks something like:

function getField fldName cardName
    push card
    go to cardName
    get field fldName
    pop card
    return it
end getField


So my question is, is there some simple, faster way to make this work without
using my silly function?

-- 

Charles.
{sun, ucbvax, pyramid, uunet}!unisoft!cander

mxmora@unix.SRI.COM (Matt Mora) (05/30/90)

In article <3015@unisoft.UUCP> cander@unisoft.UUCP (Charles Anderson) writes:

   [stuff deleted]

>I played around with stuff in the message box and found that the
>problem has something to do with having the card id in a variable.  The
>following is a example of the problem:
>
>    put field "foo" of card id 1234    -- works
>
>    put "card id 1234" into bar
>    put field "foo" of bar   -- fails

Have you tried :

     put "card id 1234 of background id 5678" into bar


>So my question is, is there some simple, faster way to make this work without
>using my silly function?

Try using the above message. I think ids are relative to their background.




>Charles.
>{sun, ucbvax, pyramid, uunet}!unisoft!cander





-- 
___________________________________________________________
Matthew Mora
SRI International                       mxmora@unix.sri.com
___________________________________________________________

jdevoto@Apple.COM (Jeanne A. E. DeVoto) (05/31/90)

In article <3015@unisoft.UUCP> cander@unisoft.UUCP (Charles Anderson) writes:
[trying to get information from a card specified by ID]

>    put field "foo" of card id 1234    -- works
>
>    put "card id 1234" into bar
>    put field "foo" of bar   -- fails
>
>If I go to the card everything works fine, so I have written a function
>that looks something like: [function deleted]

This is Yet Another Parser Subtlety (doesn't look like a bug, offhand).
There are a couple of easy ways to work around:

 - put just the ID into the variable. You would use

    put the short ID of this card into bar
    -- do some stuff
    put field "foo" of card ID bar

 - use the ever-useful "do":

    put "card id 1234" into bar
    do "put field" && quote & "foo" & quote && "of" && bar
-- 
========= jeanne a. e. devoto ========================================
 jdevoto@apple.com     |  You may not distribute this article under a
 jdevoto@well.sf.ca.us |  compilation copyright without my permission.
______________________________________________________________________
 Apple Computer and I are not authorized      |        CI$: 72411,165
 to speak for each other.                     |  AppleLink: SQA.TEST