>I want to build a system for automatically tracking version 
>information for my stacks. What I'm thinking is storing version 
>information in a property of the stack, and updating that 
>information each time the stack is saved. But I don't see any way to 
>intercept the save message (MC doesn't let you write an "on save" 
>handler in your script). Is this possible? Has anyone else created a 
>system for version tracking that they would share?
>
>TIA,
>Leston

As I frequently save during editing sessions, I'd avoid a scheme that 
updated version information after every save.

Instead, I'd trap the quit and do any version updating and stack 
saving there - handle the 'closeStackRequest' message.  This will 
allow you to save the new version as a property of the stack and to 
'save this stack' before quitting.

However, rather than embed the version number in the stack, I tend to 
use a control file that contains program name, copyright, version 
information.  You can make your stack read the contents of such a 
control file into a single stack property "controlParams" say.  I 
make sure that this only happens when running in development mode 
which means that I can control updates by simply editing the control 
file which is just a text file.

In preOpenStack I call "getParams" which reads the control file and 
sets the stack property if in developer mode, and then reads the 
various parameters from the stack property for program name, version, 
etc.

A more sophisticated versions of the same approach uses two control 
files - one which is read ONLY in developer mode (containing 
copyright info etc.) and the other which is read at start-up 
(allowing some local customising).  So I have a "master.txt" which is 
read in developer mode and a "control.txt" which is read every time. 
I call the following handler to get the parameters:

on getParams
   global gProgPath -- this must be set prior to entry
   global gProgName, gProgVersion  -- these are read from "master.txt" 
& "control.txt"
   if "Development" is in the environment then
     -- only in developer mode upload master control params:
     put gProgPath & "master.txt" into controlFile
     if there is a file controlFile then
       open file controlFile for read
       read from file controlFile until eof
       close file controlFile
       set the MasterParams of this stack to it
     end if
   end if
   -- always read general control params:
   put gProgPath & "control.txt" into controlFile
   if there is a file controlFile then
     open file controlFile for read
     read from file controlFile until eof
     close file controlFile
     set the ControlParams of this stack to (the MasterParams of this stack) \
         & return & it
   else
     set the ControlParams of this stack to (the MasterParams of this stack) \
         & return & the ControlParams of this stack
   end if
   put the ControlParams of this stack into ctrlParams
   put empty into makeParamsScript
   set itemDelimiter to "="
   repeat with i = 1 to number of lines in ctrlParams
     put line i of ctrlParams into paramLine
     if first char of paramLine <> ";"  and paramLine is not empty then
       put item 1 of paramLine into theParam
       put item 2 of paramLine into theValue
       put "global " & theParam & ";" after makeParamScript
       put "put " & quote & theValue & quote & " into " & theParam & 
return after makeParamScript
     end if
   end repeat
   set itemDelimiter to comma
   if makeParamScript is not empty then
     doScript makeParamScript
   end if
   set the title of this stack to gProgName && gProgVersion
end getParams

on doScript theScript
   repeat for each line theLine in theScript
     do theLine
   end repeat
end doScript


The control.txt and master.txt files are plain text, use a leading 
";" as a comment character, ignore blank lines, and initialise a 
series of global values.  The following are simple examples of the 
content of such files:

"master.txt":
; Master Control Params for My Program
gProgName=My program
gProgAuthor=Reid-IT Limited � 2000
gProgDevSys=MetaCard � 2000 MetaCard Corporation

"control.txt":
; Control Params for Bombay Company Catalogue
gProgVersion=v0.1
gProgDate=10 November 2000

; Output media (voice, text, both):
gOutputMedia=both
gVoiceCapable=true
gModeSelectable=true

Having run my "getParams" the various globals 'defined' in the two 
control files are initialised.

I find this scheme, whilst a bit more complicated, very flexible 
allowing me to make the changes I want and allow the end user to make 
changes whilst preserving my copyright and other information.

I hope this helps!

Cheers
Peter
-- 
--------------------------------------------------------
Peter Reid
Reid-IT Limited, Loughborough, Leics., UK
Tel: +44 (0)1509 268843 Fax: +44 (0)870 052 7576
E-mail: [EMAIL PROTECTED]
Web: http://www.reidit.co.uk

Archives: http://www.mail-archive.com/[email protected]/
Info: http://www.xworlds.com/metacard/mailinglist.htm
Please send bug reports to <[EMAIL PROTECTED]>, not this list.

Reply via email to