[comp.sys.mac.hypercard] Problem with pathnames

lrasmuss@dante.nmsu.edu (Linda Rasmussen) (07/18/89)

Can anyone help me with an (apparently)Fsimple problem concerning
pathnames to external applications?  I am using the commands

   open application
   open "document" with application
   open "adisk:afile:aaplication"

in button scripts, and HC seems unable to remember or use pathnames, 
either from the Home Stack cards, or from the scripts I provide.  Hence,
each time I reopen HC and use the buttons I have to tell it where the
applications are.  It *usually* remembers during a single session.

Another (related?) problem that came up at the same time is that
my HC application keeps reverting to User Level 2 (typing) after I quit,
despite the fact that both User Preferences and stack protection are 
set at Scripting.  When I go to User Prefs from the Home Card to reset
the level to Scripting, the Scripting bullet is still highlighted
but it immediately bounces up to Typing.  Then it resets without a problem--
until I quit HC.  I "solved" this problem without really solving it--
by inserting a "set userLevel to 5" command in the Home stack script;
it just overrides whatever screwy is going on.

Thanks in advance for any help.

         Linda Rasmussen                  lrasmuss@dante.nmsu.edu
         New Mexico State University           (505)646-5598

RADSOFT@APPLELINK.APPLE.COM (Richard Eames) (07/19/89)

In article <281@opus.NMSU.EDU> lrasmuss@dante.nmsu.edu (Linda Rasmussen) 
writes:
> Can anyone help me with an (apparently)Fsimple problem concerning
> pathnames to external applications?  I am using the commands
> 
>    open application
>    open "document" with application
>    open "adisk:afile:aaplication"
> 
> in button scripts, and HC seems unable to remember or use pathnames, 
> either from the Home Stack cards, or from the scripts I provide.  Hence,
> each time I reopen HC and use the buttons I have to tell it where the
> applications are.  It *usually* remembers during a single session.


Okay, if you have given if the pathname in a script, HyperCard does not 
store it in the Homestack--It only does that if it puts up the standard 
SFGetFile dialog.  One way around this is to manually put the pathname 
into the homestack.  Like this:

If the Original Script was:

On OpenMe
   put "My  Hard Disk:My Folder:My Application" into myPath
   lock screen
   push card
   go to card <<Whatever the name of that card is>> of stack home
   put myPath after field <<Don't know the name of the field>>
   pop card
   open MyPath
End OpenMe


--From that point, you should be able to just use the application name.


##############################################  These thoughts are mine, not
#  "Anyltus and Meletus have the Power to    #  Apple Computer's.  Blame me, 
#   put me to death, but not to harm me." -- #  not them.
#                  SOCRATES                  #
##############################################

RADSOFT@APPLELINK.APPLE.COM (Richard Eames) (07/19/89)

In article <2889@internal.Apple.COM> RADSOFT@APPLELINK.APPLE.COM (Richard 
Eames) writes:
> Okay, if you have given if the pathname in a script, HyperCard does not 
> store it in the Homestack--It only does that if it puts up the standard 
> SFGetFile dialog.  One way around this is to manually put the pathname 
> into the homestack.  Like this:
> 
> If the Original Script was:
> 
> On OpenMe
>    put "My  Hard Disk:My Folder:My Application" into myPath
>    lock screen
>    push card
>    go to card <<Whatever the name of that card is>> of stack home
>    put myPath after field <<Don't know the name of the field>>
>    pop card
>    open MyPath
> End OpenMe
> 
> 
> --From that point, you should be able to just use the application name.

Whoops!  I should have said the script should look like this:

 On OpenMe
    put "My  Hard Disk:My Folder:" into myPath    --We only gie it                                                  
    lock screen                                   --the path to the folder!
    push card
    go to card "Applications" of stack home
    put myPath & Return after field "Paths"
    pop card
    getHomeInfo   --see expanation below
    open <<Application>>
 End OpenMe



A lot of people don't realize that when HyperCard calls the Launch procedure, 
(And I am not exactly sure of the order of these...) it first looks in the HyperCard folder, then the System folder, then it rips through the global "Applications" for all of the pathnames stored in th home stack.  That global only gets updated with the call to GetHomeInfo, so we have to call it so HyperCard will know that we have put a new path in the field.  From there, everything should rip along just fine...

Have Fun!

Rick Eames


##############################################  These thoughts are mine, not
#  "Anyltus and Meletus have the Power to    #  Apple Computer's.  Blame me, 
#   put me to death, but not to harm me." -- #  not them.
#                  SOCRATES                  #
##############################################

dlugose@ecsvax.UUCP (Dan Dlugose) (07/19/89)

In article <281@opus.NMSU.EDU> lrasmuss@dante.nmsu.edu (Linda Rasmussen) writes:
>
>
>Can anyone help me with an (apparently)Fsimple problem concerning
>pathnames to external applications?  I am using the commands
>
>   open application
In this case the path is taken from the home stack, card with applications
But, if you update this card with paths, I think you have to quit
and restart HyperCard.  Also, with a syntax error on the path, that
entry is ignored.
>   open "document" with application
>   open "adisk:afile:aaplication"
This case is more foolproof in the short run, but see caveats above.
But, if you ever move applications around in the directory structure,
you may have many buttons that don't work, so I usually avoid 
pathnames except in my Home stack cards "Look for ... in"
Also remember if a disk goes offline, e.g. Appletalk server or other
external disk, HyperCard will ask "Where is..." instead of something
like "No disk HD40: online"
>
>in button scripts, and HC seems unable to remember or use pathnames, 
>either from the Home Stack cards, or from the scripts I provide.  Hence,
>each time I reopen HC and use the buttons I have to tell it where the
>applications are.  It *usually* remembers during a single session.
Make sure you don't have two "Home" stacks.
>
>Another (related?) problem that came up at the same time is that
>my HC application keeps reverting to User Level 2 (typing) after I quit,
       I would run a stack reporter to get all the scripts in your
stack and the Home stack.  At some level there is a handler that sets
the userlevel to 2.  Start by looking for an "On closeStack " handler
in the stack script (or background script) of your stack, followed by
looking for such a handler in your home stack.  But there are other
places it could be.  A stack can have scripts you did not consciously
create, e.g. do a new stack while at the Home stack with "copy 
background" active.  Also don't assume you already know what's in the
script of your Home stack.  Other stacks modify it.
>despite the fact that both User Preferences and stack protection are 
>set at Scripting.  When I go to User Prefs from the Home Card to reset
>the level to Scripting, the Scripting bullet is still highlighted
>but it immediately bounces up to Typing.  Then it resets without a problem--
     The hilite of this button gets corrected when the card opens.
So if you set it to 5 on this card, go to another stack and come back,
if the closestack handler sets userlevel to 2, the userlevel really
is two, but when you look at this card, you'll see the button change
from 5 to 2.
>until I quit HC.  I "solved" this problem without really solving it--
>by inserting a "set userLevel to 5" command in the Home stack script;

Dan Dlugose
UNC Educational Computing Service