[comp.sys.mac.hypercard] Button Name

cs004004@brunix (Jon Feinberg) (05/10/89)

I am having a rather frustrating problem... the solution is probably
obvious, so please enlighten me.
I am simply trying to have a button modify its own name like so:

on mouseUp
   if name of me is "ShowIt" then
     set name of me to "HideIt"
   else
     set name of me to "ShowIt"
   end if      
end mouseUp

I have tried infinite variations on this theme, including  
having the button refer to itself by id, etc.

Furthermore, if I have the button start out named "HideIt," the first
mouseUp sent to it will indeed change the name to "ShowIt," but
subsequent presses are utterly ineffectual.

I have written some lovely and funky scripts, but this sucker ne marche pas.
Help!!

Jonathan Feinberg
cs004004@pebbles.cs.brown.edu

bvsy@vax5.CIT.CORNELL.EDU (05/10/89)

In article <6035@brunix.UUCP> cs004004@cslab9d.UUCP (Jon Feinberg) writes:
>I am simply trying to have a button modify its own name like so:
>
>on mouseUp
>   if name of me is "ShowIt" then
>     set name of me to "HideIt"
>   else
>     set name of me to "ShowIt"
>   end if      
>end mouseUp
>
 
You should use short name of me.  ie if short name of me is "ShowIt".
Using just name of me returns the full title of the object-
bkgnd button "ShowIt" or card field "Hide" etc..

wing
ygxj@vax5.cit.cornell.edu
ygxj@cornella.bitnet
  

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

In article <6035@brunix.UUCP> cs004004@cslab9d.UUCP (Jon Feinberg) writes:
>I am simply trying to have a button modify its own name like so:
>
>on mouseUp
>   if name of me is "ShowIt" then
>     set name of me to "HideIt"
>   else
>     set name of me to "ShowIt"
>   end if      
>end mouseUp

>Furthermore, if I have the button start out named "HideIt," the first
>mouseUp sent to it will indeed change the name to "ShowIt," but
>subsequent presses are utterly ineffectual.

The conditional line should read:

   if short name of me is "ShowIt" then
      ^^^^^

When a script isn't behaving as expected, and you're dealing with a
function result, put it into the message box to make sure it's really
returning what you you think it should (i.e. "put the name of me").

-- 
void *Wayne_Mesard();  "Save Money! Use your new BayBank Visa or MasterCard to
Mesard@BBN.COM          pay off your other bank credit cards that charge higher
BBN, Cambridge, MA      interest rates."  -Lies my junk mail told me.

marvel@tut.cis.ohio-state.edu (Howard P Marvel) (05/10/89)

In article <39723@bbn.COM> mesard@BBN.COM (Wayne Mesard) writes:

>   if short name of me is "ShowIt" then

The alternative is to use name and contains,

	if the name of me contains "ShowIt" then

mst@csun.edu (05/10/89)

In article <6035@brunix.UUCP> cs004004@cslab9d.UUCP (Jon Feinberg) writes:
>I am having a rather frustrating problem... the solution is probably
>obvious, so please enlighten me.
That depends...

>I am simply trying to have a button modify its own name like so:

The problem looks to be in the 2nd line, I believe it should be
"the short name of me".  Try typing "the short name of card btn 1" and
"name of card btn 1" in the message box.  You will see the difference.

on mouseUp
   if the short name of me is "ShowIt" then
     set name of me to "HideIt"
   else
     set name of me to "ShowIt"
   end if      
end mouseUp

>Jonathan Feinberg

Mike Temkin

martin@m2.csc.ti.com (Steven Martin) (05/11/89)

In article <6035@brunix.UUCP> cs004004@cslab9d.UUCP (Jon Feinberg) writes:
>I am having a rather frustrating problem... the solution is probably
>obvious, so please enlighten me.
>I am simply trying to have a button modify its own name like so:
>
>on mouseUp
>   if name of me is "ShowIt" then
>     set name of me to "HideIt"
>   else
>     set name of me to "ShowIt"
>   end if      
>end mouseUp

This is a common problem.  It got me for a while too.

the name of me --> 'cd button "ShowIt"'   (or whatever)

what you need is "the short name of me"  which just returns '"Showit"'

That should do it.

Steve Martin            USENET: {ctvax,im4u,texsun,rice}!ti-csl!martin
                        ARPANET: SMARTIN@CSC.TI.COM  COMPUSERVE: 72727,1471
                        GENIE: S.MARTIN8    PHONE: (214)-995-0698, 404-1061
What I am is what I am, are you what you are or what?