bc@apple.com (bill coderre) (09/07/90)
Since 2.0 is supposedly in the pipeline, let me share this handler that will provide version control at the click of a mouse. Sorry, it does rely on several new features to HC 2.0 and therefore cannot run under 1.2.5. If you include this handler in any stack that has a name like "MyStack 1", triggering VersionSave will change the name of the stack to "Mystack 2" and save a copy under the old name. All errorchecking that I know about is performed, the stack is compacted, and the message box (which is used to issue progress reports) is restored to its original state. By using the handler, you can store a backup trail of your stack very quickly and easily, and save your stack any time you like. With a 200K stack on a Mac Plus with a good hard drive, the operation will take less than 30 seconds. DANGER: Make sure your scripts are saved (and preferably CLOSED) before running. Of course, since the name of the stack changes, the documented Multifinder bug (see the Hypertalk Handbook) will be in effect: other stacks will not be able to find your stack under its new name until an open folder that displays the stack is closed and then opened. NOTE: In the following script, the tilde character (~) is used to represent Hypercard's "continued on next line" character that is not available in standard ASCII. on VersionSave -- Version Control System, copyright 1990 bill coderre -- This program may be distributed freely with this copyright -- notice intact. -- start to calculate the new name of the stack put the short name of this stack into name put the second word of the long name of this stack into namepath delete the first character of namepath delete the last character of namepath put name into newname get the last word of name -- check for proper stack name syntax if it is not an integer then answer "The stack name doesn't end with a number." ~ & return & return & "Can't do version control." with "Cancel" exit to Hypercard end if -- ok, so make the new name add 1 to it put it into the last word of newname put it into the last word of namepath -- check for overwriting an existing stack if there is a stack namepath then answer "There is already a stack called" && quote & ~ newname & quote & "." & return & return & ~ "Can't do version control." with "Cancel" exit to Hypercard end if -- check for new name too long if the number of characters in newname > 29 then answer "The new name of this stack (" & quote & ~ newname & quote & ") is too long." & return & return & ~ "Can't do version control." with "Cancel" exit to Hypercard end if -- check for enough diskspace put the size of this stack into mySize put the freeSize of this stack into myFree if 2 * (mySize - myFree) > the diskSpace then answer "There isn't enough disk space to proceed." ~ & return & return & ~ "Can't do version control." with "Cancel" exit to Hypercard end if -- stow the message box visibility and contents put msg into mtemp put the visible of msg into mvis -- Compact the stack put "Compacting stack..." doMenu "Compact Stack" -- now change the name of the stack to the new name put "Updating stack version number..." set the name of this stack to newname -- save a copy under the old name save this stack as name -- stow the message box visibility and contents put mtemp into msg set the visible of msg to mvis end VersionSave
bc@Apple.COM (bill coderre) (09/08/90)
Please excuse my inappropriate posting. I was certain I had typed comp.sys.mac.hypercard ("dot long dot name dot dot dot "), but the lateness of the hour, etc. etc. Next time I'll wait until I am awake before posting.