[comp.sys.mac.hypercard] Creating a stack via Hypertalk?

peterbak@microsoft.UUCP (Peter BAKO) (03/21/90)

I'm putting a stack together which needs to have a function that will
create a new stack with the name that is already residing in a card
field.  Furthermore this new stack must have the same identical
first four cards as the stack which created it.  If there is any way 
for a script to paste a name into the Save a copy... dialog, then I
could use that, and then delete any cards which have a card number
greater then four.  Can anyone offer a better method?

Also is there any way that I can detect if a user has double clicked
on a button?  If yes, how?

Peter
 
-- 
(*)-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-\/-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+(*)
(   UUCP:         peterbak@microsoft  ||   Is this all that I am?  Is there   )
(   CompuServe:   71170,1426          ||   nothing more?    - V'ger           )
(*)-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-/\-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+(*)

tim@hoptoad.uucp (Tim Maroney) (03/22/90)

In article <53654@microsoft.UUCP> peterbak@microsoft.UUCP (Peter BAKO) writes:
>I'm putting a stack together which needs to have a function that will
>create a new stack with the name that is already residing in a card
>field.  Furthermore this new stack must have the same identical
>first four cards as the stack which created it.  If there is any way 
>for a script to paste a name into the Save a copy... dialog, then I
>could use that, and then delete any cards which have a card number
>greater then four.  Can anyone offer a better method?

Not a clean one, but it can be done.  Do a New Stack command, then
copy each card you need across to it using "doMenu Copy Card" and
"doMenu Paste Card", with push/pop card commands to handle most of
the inter-stack movement.  Delete the first card of the new stack
when you're done.

I ran into a similar problem, except my stacks needed to copy eighty
cards.  I basically just gave up.  I make the changes that are needed,
which are only on the stack's first card, then I issue a doMenu
Save a Copy..., then I revert the first card to its original state.
I'd like to both go to the newly created stack and save its name
and folder in the master stack, but there's doesn't seem to be any
way to do this without either writing a copy stack XCMD or patching
file system traps to record the location.

>Also is there any way that I can detect if a user has double clicked
>on a button?  If yes, how?

Easy.  Just store the time between the first mouseUp and the second
mouseDown in a global.  It goes something like this:

on mouseUp
  global lastUp,lastClick
  put the ticks into lastUp
  put the mouseLoc into lastClick
end mouseUp

on mouseDown
  global lastUp,lastClick
  if lastUp is not empty and the ticks - lastUp < 20 and 
  abs(item 1 of lastClick - item 1 of the mouseLoc) < 3 and
  abs(item 2 of lastClick - item 2 of the mouseLoc) < 3 then
    send "doubleClick" to me -- put action in an "on doubleClick" handler
  end if
  put empty into lastUp
end mouseDown

Of course, you'll have to put option-L's in the conditional to make
it all look like it's on one line.  I don't want to screw up anyone's
terminal emulator by putting them here.
-- 
Tim Maroney, Mac Software Consultant, sun!hoptoad!tim, tim@toad.com

"He goes on about the wailing and gnashing of teeth.  It comes in one
 verse after another, and it is quite manifest to the reader that there
 is a certain pleasure in contemplating the wailing and gnashing of
 teeth, or else it would not occur so often."
	-- Bertrand Russell, "Why I Am Not a Christian"

masinter@parc.xerox.com (Larry Masinter) (03/22/90)

The copyfile xcmd found in the developer stack seems to work just fine
on the current stack. For example, I use the following "backup" script
to copy the stack I'm working on to a backup Tops directory:

  get the long name of this stack
  delete word 1 of it
  delete char 1 of it
  delete last char of it
  get copyfile(it,"backup:"&the short name of this stack)
  if it is not 0 then put "backup failed"



--
Larry Masinter (masinter@parc.xerox.com)
Xerox Palo Alto Research Center (PARC)
3333 Coyote Hill Road; Palo Alto, CA USA 94304

davide@cs.qmw.ac.uk (David Edmondson) (03/23/90)

>In article <53654@microsoft.UUCP> peterbak@microsoft.UUCP (Peter BAKO) writes:
>>I'm putting a stack together which needs to have a function that will
>>create a new stack with the name that is already residing in a card
>>field.  Furthermore this new stack must have the same identical
>>first four cards as the stack which created it.  If there is any way
>>for a script to paste a name into the Save a copy... dialog, then I
>>could use that, and then delete any cards which have a card number
>>greater then four.  Can anyone offer a better method?
>

I did something like this by using File Copy XCMD (written by
Chris Hyde here at QMW since I couldn't find one anywhere else)
and a File Rename XCMD which I think came off an early
Developer Stack.  I needed to create a variety of stacks so I
kept a template of each, copied and renamed the file and did
the stack specific stuff from a script, if the stuff on the
first four cards is variable then you can copy the stack you
are in (if the XCMD doesn't let you copy an active stack you
may have to go to the home stack temporarily but with a
lockscreen the user will never know). At the time the rename
XCMD was also a good way of checking to see if a stack already
existed, attempt to rename the stack to the same name and you
know it isn't there if you fail.

Dave

peterbak@microsoft.UUCP (Peter BAKO) (03/28/90)

In article <1821@sequent.cs.qmw.ac.uk> davide@cs.qmw.ac.uk (David Edmondson) writes:
>>In article <53654@microsoft.UUCP> peterbak@microsoft.UUCP (Peter BAKO) writes:
>>>I'm putting a stack together which needs to have a function that will
>>>create a new stack with the name that is already residing in a card
>>>field.  Furthermore this new stack must have the same identical
>>>first four cards as the stack which created it.  If there is any way
>
>I did something like this by using File Copy XCMD (written by
>Chris Hyde here at QMW since I couldn't find one anywhere else)
>and a File Rename XCMD which I think came off an early
>Developer Stack.  I needed to create a variety of stacks so I



I would like to thank everyone who responed to my question, and to
post how I was finally able to find an acceptable solution.

On the "Phil&Dave's Excellent" CD there is a stack by the title of 
"NavStack".  One of the XFNC within it is called FileCopy.  It takes
two arguments (source file, dest file) and copies file one into the
second name.  I supply the second name from a cd fld, and give it the
name of the current stack as the source file.  WHen the copy is done,
I simply jump to the new stack, and delete all the cards above
four.  It may not be the most elegant solution, but it does work.

Peter

-- 
(*)-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-\/-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+(*)
(   UUCP:         peterbak@microsoft  ||   Is this all that I am?  Is there   )
(   CompuServe:   71170,1426          ||   nothing more?    - V'ger           )
(*)-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-/\-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+(*)