Revised Font Chooser and Preferences stacks

J. Landman Gay jacque at hyperactivesw.com
Tue May 16 14:07:03 CDT 2006


Richard Gaskin wrote:

> Yes, I use the answer file extensions all the time, but I guess I'll 
> have to see it in place to understand how file filtering will determine 
> file format....
> 

Well, here you go. I'll post this here so that anyone who wants to make 
the swap without waiting for the next IDE can do so. To recap:

The "Save As" menu item has been changed to allow you to choose the 
stack file format you want to save the stack in, either "Legacy MC 
Stack" or "Metacard Stack". The choices only appear if you are running 
engine version 2.7 or higher. In engine 2.6.1 or less, you should not 
see anything different in the save dialog.

I learned that 2.6.1 cannot compile this statement and will error:

   set the stackfileversion to tVers

because it can't set an unknown engine property. However, I also found 
that you can bypass this by breaking the statement up into an artificial 
"do" construct; you don't even need to store the statement in a custom 
property. Since "do" statements don't compile until runtime, if you 
provide the appropriate branching behavior you get no errors in older 
engines. Thus, this works in all engines:

   if the version >= 2.7 then do "set the stackfileversion to" && tVers

Handy little tip to know.

If you want to update your Save As handler, open the script for button 
"menuButton" of group "MetaCard Menu Bar" of card "Menu Bar card" of 
stack "mctools". Find the "MCdoSaveAs" handler and replace it with the 
one below. Watch for text wrap, I hope it isn't too bad to use.

Richard, if you want to roll this into the next IDE release, I think it 
is ready to go. But if anyone finds bugs, let me know.

**** replacement mcSaveAs start ******

on MCdoSaveAs shortname
   local makems, msname, sname
   local tStackVers,tOldVersion -- jg 5/14/06
   put true into makems
   put the short name of stack shortname into shortname
   put the mainStack of stack shortname into msname
   if msname is not shortname and msname is not "Home" then
     modal "MainStack Option"
     if the retval of stack "MainStack Option" is "Cancel"
     then exit to MetaCard
     if the retval of stack "MainStack Option" is "No" then
       put false into makems
       put msname into shortname
     end if
   end if
   put MCfixpath(shortname) into sname
   local filterstring
   if the systemFileSelector then
     switch the platform
     case "Win32"
       put "MetaCard Stacks" & cr & "*.mc" & cr & "All Files" & cr & 
"*.*" into filterstring
       break
     case "MacOS"
       put "MSTK" into filterstring
       break
     default
       put "*.mc" into filterstring
     end switch
   else put "*.mc" into filterstring
   # -- jg 5/14/06 start:
   # -- Added support for the stackFileVersion so stacks can be saved in 
either
   # -- 2.4 or 2.7 format. The unusual "do" constructs below prevent 
errors when
   # -- running the MC IDE with engine versions less than 2.7. Without 
"do" the
   # -- script will not compile. -- jacque gay
   if the version < 2.7 then
     ask file "Save stack" && shortname && "as:" with sname with filter 
filterstring
     put "" into tStackVers
   else
     do "put the stackfileversion" && "into tOldVersion"
     put "MetaCard legacy stack|mc|MSTK" &cr& "MetaCard 2.7 
stack|mc|MSTK" into tTypes
     ask file "Save stack" && shortname && "as:" with sname with type tTypes
     if the result contains "legacy" then put "2.4" into tStackVers
     else put "2.7" into tStackVers
   end if
   if it is empty
   then exit to MetaCard
   put it into tPath
   if tStackVers <> "" then do "set the stackfileversion to" && tStackVers
   # -- end main block change, jg 5/14/06
   if makems and shortname is not msname then
     local tcolors, hcolors
     put the colors of stack shortname into tcolors
     put the colors of stack "Home" into hcolors
     repeat with i = 1 to 8
       if line i of tcolors is empty
       then put line i of hcolors into line i of tcolors
     end repeat
     set the colors of stack shortname to tcolors
     set mainStack stack shortname to shortname
     set the cursor to watch
     save stack msname
   end if
   set the cursor to watch
   save stack shortname as tPath
   if tStackVers <> "" then do "set the stackfileversion to" && 
tOldVersion -- jg 5/14/06
   put empty into stackstatus[MCtargetStack(shortname)]
end MCdoSaveAs

***** end replacement handler *****
-- 
Jacqueline Landman Gay         |     jacque at hyperactivesw.com
HyperActive Software           |     http://www.hyperactivesw.com


More information about the metacard mailing list