[comp.sys.mac.hypercard] Scripting Question

jamii@oxygen.uucp (Jamii K. Corley) (01/16/91)

 Many thanks to several people who gave me info about creating buttons on
the fly. It works nicely. I have another beginning HC programmer question.
 If I have a script attached to the openStack event, and I screw it up badly,
i.e. I have an infinite loop, is there any way to get to the script to fix it?
 After you get done laughing, if you have any suggestions I'd appreciate them.
      Thanks,
             Jamii

  -----------jamii@edsr.eds.com   or ....uunet!edsr!jamii------------------
"Everyday, once a day, give yourself a present. Don't plan it, don't wait for it
just let it happen. It could be a new shirt from the men's store, a cat nap in
your office chair, or two cups of hot black coffee." - Agent Dale Cooper, TP

Jim.Russell@f421.n109.z1.fidonet.org (Jim Russell) (01/17/91)

To fix the error in the openStack handler (assuming it is in the stack 
script) you should be able, with any other stack (like home) open, to 
just enter via the message box:
  edit the script of stack foo


--  

        Jim Russell, Jim.Russell@f421.n109.z1.fidonet.org
      via The Black Cat's Shack's FidoNet<->Usenet Gateway
          blkcat.fidonet.org   and   Fidonet 1:109/401

lou@bern.csmil.umich.edu (Lou Rosenfeld) (02/17/91)

(using HC1.2)

I would like to create a script which simply
allows me to use the select tool to erase an
area.  I can't figure out how to cut or erase
the selected area.  The script should read
something like this:

   choose select tool
   drag from 100,100 to 100,200
   ??????
   choose browse tool

Can anyone fill in the ?????
I've checked through Goodman's book and also 
looked through Apple's HyperCard Script Lan-
guage Guide.

Much appreciated.

Lou Rosenfeld

johnston@oscar.ccm.udel.edu (Bill Johnston) (02/18/91)

In article <1991Feb17.001323.13640@engin.umich.edu>, lou@bern.csmil.umich.edu (Lou Rosenfeld) writes...
>(using HC1.2)
> 
>I would like to create a script which simply
>allows me to use the select tool to erase an
>area.

>   choose select tool
>   drag from 100,100 to 100,200
>   ??????
>   choose browse tool

The missing line is:  doMenu "Clear Picture".
Please note that "Clear Picture is only available as a menu option 
when a valid selection has been made; "drag from 100,100 to 100,200"
encloses a rectange of zero area, so no selection is made.  
Something like "drag from 100,100 to 200,200" works fine.

-- Bill Johnston (johnston@oscar.ccm.udel.edu)
-- 38 Chambers St.; Newark, DE 19711; (302)368-1949 

ireland@ac.dal.ca (02/23/91)

In article <13258@hubcap.clemson.edu>, jcocon@hubcap.clemson.edu (james c oconnor) writes:
> I want a button to disappear when a field is empty and appear the
> instant a user types a character into it.  My code looks like this:
> 
> on keyDown theParm
>   send "keyDown" && theParm to this card
>   if me is empty then
>     hide card button "button"
>   else
>     show card button "button"
>   end if
> end keyDown
> 
> It works fine, except when the user types a space.  Then the message
> gets confused.  What gets passed is probably "keyDown  " and the second
> space isn't interpreted as the key.  Is there a good way around this?
> I'd like to avoid any hacks.
> 
> Jim

You could convert theParm to its ascii equivalent with chartonum(theParm).
I had to do this in a keydown handler in order to distinguish upper and lower
case letters.

Hope this helps, Keith Conover.   ireland@ac.dal.ca

jcocon@hubcap.clemson.edu (james c oconnor) (02/23/91)

I want a button to disappear when a field is empty and appear the
instant a user types a character into it.  My code looks like this:

on keyDown theParm
  send "keyDown" && theParm to this card
  if me is empty then
    hide card button "button"
  else
    show card button "button"
  end if
end keyDown

It works fine, except when the user types a space.  Then the message
gets confused.  What gets passed is probably "keyDown  " and the second
space isn't interpreted as the key.  Is there a good way around this?
I'd like to avoid any hacks.

Jim

jcocon@hubcap.clemson.edu (james c oconnor) (02/23/91)

From article <13258@hubcap.clemson.edu>, by jcocon@hubcap.clemson.edu (james c oconnor):
> on keyDown theParm
>   send "keyDown" && theParm to this card
>   if me is empty then
>     hide card button "button"
>   else
>     show card button "button"
>   end if
> end keyDown
Oops, this won't work quite right even ignoring spaces - hiding and
showing the button removes the insertion point.  Any ideas how to fix
that problem too?

Jim

kofoid@bioscience.utah.edu (Dr. Cancer) (02/23/91)

In article <13258@hubcap.clemson.edu> jcocon@hubcap.clemson.edu (james c 
oconnor) writes:
> I want a button to disappear when a field is empty and appear the
> instant a user types a character into it.  My code looks like this:
> 
> on keyDown theParm
>   send "keyDown" && theParm to this card
>   if me is empty then
>     hide card button "button"
>   else
>     show card button "button"
>   end if
> end keyDown
> 
> It works fine, except when the user types a space.  Then the message
> gets confused.  What gets passed is probably "keyDown  " and the second
> space isn't interpreted as the key.  Is there a good way around this?
> I'd like to avoid any hacks.
> 
> Jim

This script (placed in the field itself) works fine:

on keyDown theItem
  type theItem
  if me <> empty then
    show btn "test"
    select after text of me
  else
    hide btn "test"
    select after text of me
  end if
end keyDown

Cheers,

Eric.

A.G.Poole@newcastle.ac.uk (Ford (Alex Poole)) (02/26/91)

jcocon@hubcap.clemson.edu (james c oconnor) writes:

One solution to both problems is to time the hiding/showing of the button until
the enter key is pressed, ie when you have finished entering text in the field.
The script in the field could be something like:

on EnterInField
   if [card] field <fieldname> is empty then
      hide [background] button <buttonname>
   else
      show [background] button <buttonname>
   end if
   pass EnterInField
end EnterInField

This is a fairly simple answer, and may not be quite what you need; however,
since you presumably wouldn't want to press the button until you've finished
entering text, it shouldn't be a problem from that aspect.

Hope it helps!

Ford

-----

Oh screw the computer, I hope it gets plug-rot!
                                        --  The Hitch-Hikers Guide to the Galaxy