[comp.sys.mac.hypercard] Creating a new stack from a script

sharp@calgary.UUCP (Maurice Sharp) (07/08/88)

Hiya,

     I need to create a new stack in from a script.
The problem is to create one with a name that I assign
it from the script.  In other words, I can not do it
with 'DoMenu "New Stack..."' since this will bring up
a dialog for the user.

     The final script will be used to create a new
stack that consists of some selected cards from the
current stack.

     Something like this must be possible since that
is how 'Compact Stack' works, that is, it duplicates
the current stack then rearranges the stack.

      Thank you in Advance
		   Maurice

UUCP : !ihnp4!alberta!calgary!sharp

Slow Mail:

	Maurice Sharp
	c/o Knowledge Science Labs
	Department of Computer Science
	University of Calgary
	2500 University Dr. N.W.
	Calgary, Alta
	Canada
	T2N 1N4

	(phew !)

bayes@hpfcdc.HP.COM (Scott Bayes) (07/12/88)

>     I need to create a new stack in from a script.
>The problem is to create one with a name that I assign
>it from the script.  In other words, I can not do it
>with 'DoMenu "New Stack..."' since this will bring up
>a dialog for the user.
>
>     The final script will be used to create a new
>>stack that consists of some selected cards from the
>current stack.
>
>     Something like this must be possible since that
>is how 'Compact Stack' works, that is, it duplicates
>the current stack then rearranges the stack.

Please post any enlightenment you might provide or receive
on this point. I too wish to generate a name for a new Stack
without the user having to hold a dialog with HC over it.

Scott Bayes

palevich@Apple.COM (Jack Palevich) (07/15/88)

In article <10520011@hpfcdc.HP.COM> bayes@hpfcdc.HP.COM (Scott Bayes) writes:
>>     I need to create a new stack in from a script.

I solved this problem by writing a short XCMD which duplicates a file.  I use
it to make a copy of the current stack.  Then, using HyperTalk, I can go
to the new stack and delete all the cards I don't want in the copy....

The script looks like this:
on mouseUp
  -- Use any method of getting the file name here:
  put NewFileName("New stack name:", "New Stack") into newName
  if newName is empty then exit mouseUp
  put word 2 of (the long name of this stack) into oldName
  put number of characters in oldName into nOldName
  put char 2 to nOldName - 1 of oldName into oldName
  put "Creating a new stack."
  put DuplicateFile(oldName, newName) into r
  if r is not 0 then
    answer "I/O Error " & r & ".  Couldn't create " & newName & "." with "OK"
    exit mouseUp
  end if
  go to stack newName
  put "We are now in stack " & newName
end mouseUp

Here is the XFCN DuplicateFile, as a BinHexed, StuffIt-ed archive:

(This file must be converted with BinHex 4.0)

:%84eF'aTBf&dC8CTE'8ZFfPd!&0*9#&6593K!*!%"6-!!!%H(#T6593K!!%!!!8
cFNaKG3%!N!F#!"*%GA"XD@0KG'9'D@aP)&K'3dil"4`!6'X5!!#[d%#")5*!J5%
Lrri!J!%(!"m!6'X5!%#$`J!l5FJ!N!3""h*cFQ058d9%!3#I!N0NR`*$M`!!"Ri
!N!B%V3#3"#i@!*!)#I8!!!3)#-#!Mi!&$JB%3V#KJ)B!L$6m`Dq+&9@VUPA"U"%
M!5a'KMJ4m$#JR$PbaNLC8N3La)B6Z$8mQA*PbjFiFa,m*'!)QCF'r$b!Ta2!8)T
rr2eEbV4T8ST$F3i!8$*L`!$!X'S&eM$2-kpH'flG@V5X@33!d!BNFJ"!flGZ#4E
3iF4+hY)cJfb!B-*0@MJ#B%dj`k!((i(rr2%*!#DJ*4"VU,k!J-402hp1G"&`82P
bCJ)d)"HFA0NICPd$m*8q6F"$jF5V-`2!a!2!NhF!3*LK)Z5)&$H*B4a!!Z`&J0@
G6`IJ9[Xf!!D%BqX#B!h,)c!ST"aKF)4U'fHrBEXaR9`f[YT3(Te4)"d!+qX[&X!
`30aijEZC"q$)mLMqIAZC#H$1#9m!)!36hb!!M"0HZ2#*%h8d3N398$#4a"""8&'
%%8N`884!GId$5ei"B)##A`cdP9B,5r`MM"$!'51%#rmS)`8996cb'La#R*'I0cj
mX"jhre4c"J(#JH%"Lbl#q)q-00U)Sil!mHJMDU3%+4b#'!$#))500"(''Q88d3B
FG14K4"TXP!'L&5+5b*GI#$$jBS`ceTMMMMhQCiH@"b#)J*GH3+J)%@@d58FCDlC
*8)KJN!"S)SSU)Z!IF'$)jX9"4bDT``X-l#JE%j`LH3"f,3#(bMriT2S2+rr`ibS
Jrd$M+L(r8,0RPAfLTJ1J6,M6j6p8I&N()d1m!BHDE*D4K"YQ[2'S&3(P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9KC!#3$3(6*3#
3")S!N#)"X#8!N!5+#N&`F'aP8fKKFQ8!N"%"!*!$!3#3#"i!N!NF!"lrrkC#!:

beloin@batcomputer.tn.cornell.edu (Ron Beloin) (07/17/88)

In article <10520011@hpfcdc.HP.COM> bayes@hpfcdc.HP.COM (Scott Bayes) writes:
>>     I need to create a new stack in from a script.
>>The problem is to create one with a name that I assign
>>it from the script.  In other words, I can not do it
>>with 'DoMenu "New Stack..."' since this will bring up
>>a dialog for the user.
.
>
>Please post any enlightenment you might provide or receive
>on this point. I too wish to generate a name for a new Stack
>without the user having to hold a dialog with HC over it.
>
>Scott Bayes

I just copied this from the developer's stack, v. 1.2r :
The CopyFile XFCN was written by Brad J. Hicks to give HyperCard
 the ability to copy a file (such as a stack) with full script
 control (necessary for making backup copies of a stack automatically,
 for example).

Use it freely, but I would appreciate a thank-you or acknowledgement somewhere in the stack.  

Brad J. Hicks
FidoNet:
1:100/523
CompuServe:
[76012,300]
SUS Mail:
11215 Sugartrail
St. Louis, MO 63136

Seems like one could use this xfnc to copy a template stack that
was make ahead of time and rename it (there is also a rename xfnc)
completely under script control.
Ron Beloin, Ecosystems Research Center, Corson Hall, Cornell, Ithaca,NY 14853
>> opinions << BITNET:BELOIN@CRNLTHRY; INTERNET:beloin@tcgould.tn.cornell.edu
>> are mine << UUCP:{cmcl2,shasta,uw-beaver,rochester}!cornell!tcgould!beloin

bayes@hpfcdc.HP.COM (Scott Bayes) (07/21/88)

I've received one mail response to the "New Stack..."  question, to
which I could not reply (thank you for the mail, Mr.  Langford), and
have seen a response here that both suggest keeping a template stack,
and duping that in one way or another.  This I had hoped to avoid, as I
would like to minimize the number of "control" stacks:  I already need 1
"data" stack for each user (golfer).

Having a template card in the 1 control stack and doing "new stack" with
copy current background checked would fill the bill almost perfectly, if
I could script the dialog response for the new stack...  menu item. Each
data stack needs only 1 background.

If I can't find out how to do the above, I'll dup a template stack.

Many Thanks
Scott Bayes