[comp.sys.mac.hypercard] help with choose command

murray@andromeda.rutgers.edu.rutgers.edu (Murray Karstadt) (08/02/89)

    I want to use the choose command with info read from a field. Something 
    like:
    
       choose field 1 tool
       
       
    which as I understand it should read the info out of field 1. I have the
    word brush on a line by itself. When I use this command I get the following
    error
    
        Can't understand arguments to command choose
    
    I must be missing something here but I just can't see it.
    
    thanx for any help
    
    murray
    

englandr@phoenix.Princeton.EDU (Scott Englander) (08/03/89)

In article <Aug.1.15.59.20.1989.6372@galaxy.rutgers.edu> murray@andromeda (Murray Karstadt) writes:
>
>    I want to use the choose command with info read from a field. Something 
>    like:
>    
>       choose field 1 tool

You need to use the "do" command.  First assemble your command string.
Then "do" the string:

put "choose " & field 1 && "tool" into cmdstr
do cmdstr


I tried it and it works!  BTW, you won't be able to do this from the
message box. 
-- 

                                               - Scott

baum@Apple.COM (Allen J. Baum) (08/04/89)

[]
>In article blahblahblah (Scott Englander) report on how to choose with a
variable:
>>
>>    I want to use the choose command with info read from a field. Something 
>>    like:
>>    
>>       choose field 1 tool
>
>You need to use the "do" command.  First assemble your command string.
>Then "do" the string:
>
>put "choose " & field 1 && "tool" into cmdstr
>do cmdstr

So, what are the rules that determine when a "Do" is necessary, and when a
variable can simply be used?

--
		  baum@apple.com		(408)974-3385
{decwrl,hplabs}!amdahl!apple!baum

jm7f+@andrew.cmu.edu (Joe Melvin) (08/04/89)

regarding when the use of the "do" command is necessary and when it is
not, here is one rule:

try it the straightforward way.  If hyperCard gets confused, use "do".

I know the command is needed in some cases, but in others it seems like
things should work without it.  The example that has been recently discussed,
"choose field 1 tool",  does seem like the do command would be needed if you
think about it.  There is a field tool, so hyperCard probably thinks your
command is starting out as "choose field" and expects the next word to be
"tool", then it runs into the "1" and gets confused.
Joe Melvin
HyperCard Programmer & student
Carnegie Mellon University

mesard@bbn.com (Wayne Mesard) (08/05/89)

In article <QYqA4By00WB3EHVWFb@andrew.cmu.edu> jm7f+@andrew.cmu.edu (Joe Melvin) writes:
>regarding when the use of the "do" command is necessary and when it is
>not 
[...]
> The example that has been recently discussed,
>"choose field 1 tool",  does seem like the do command would be needed if you
>think about it.  There is a field tool, so hyperCard probably thinks your
>command is starting out as "choose field" and expects the next word to be
>"tool", then it runs into the "1" and gets confused.

But if that were true then "choose (field 1) tool" WOULD work and it
doesn't.

Here's the rule:

 If you're trying to use a container (field, string, variable) and the
 description of the command in The Book doesn't indicate that a
 container is valid, then you have to use "do".

"Choose" doesn't accept container's.  It wants a keyword.  (I.e.,

   choose "field" tool     -- will NOT work!)

-- 
unsigned *Wayne_Mesard();       "We need your business, we're going out of
Mesard@BBN.COM                   business, we'll give you the business."
BBN, Cambridge, MA                             -Tom Waits, "Step Right Up"