We make software for humans. Custom Mac, Windows, iOS and Android solutions in HyperCard, MetaCard, and RunRev LiveCode
Let's start. Make a copy of Tech Support TimeSaver for safekeeping, and then open the stack in HyperCard. Take a look around to become familiar with the stack and what it does. Look at the various scripts to see how it works.
Removing menus: The first thing we will do is remove or comment out those script segments which are incompatible with LiveCode. Removing these items before the conversion will prevent LiveCode from putting up multiple error messages while trying to compile these scripts.
As mentioned in the General Conversion Guidelines, menu references are one of the things we need to address. Open the stack script in the script editor and note the many references to creating and managing menus, and the use of a doMenu handler. We will change these. Comment out the items that are marked in red below, and add the makeIndexMenu stub as noted:
The makeIndexMenu stub is just a trap that does nothing. Because the real makeIndexMenu handler will error in LiveCode, we do not want it active. However, many scripts elsewhere in the stack make calls to makeIndexHandler. Rather than track down and comment out all those calls, we will just add this stub temporarily in order to catch them.on openStack global gTimerOpenOrClosed,gShowDialog put "Closed" into gTimerOpenOrClosed put "Yes" into gShowDialog hide message -- if there is no menu "Index" then create menu "Index" makeIndexMenu pass openStack end openStackon makeIndexMenu -- ADD THIS STUB end makeIndexMenu
-- on makeIndexMenu -- updates Index menu global gNumUntitled put empty into menu "Index" put "1" into gNumUntitled repeat with i=1 to number of cards of bg "Records" set cursor to busy get line 1 of bg field "Product Name" of card i of bg "Records" if it is not empty then put it after menu "Index" set menumsg of menuItem i of menu "Index" to "go to card" \ &&i&& "of Bg" &"e& "Records" "e else put "(Untitled #" & gNumUntitled & ")" after menu "Index" add "1" to gNumUntitled set menumsg of menuItem i of menu "Index" to \ ("go to card" &&i&& "of Bg" &"e&"Records""e) end if end repeat end makeIndexMenu
-- on doMenu item if item is "New Card" then newCardHandler exit to HyperCard else if item is "Delete Card" then deleteCardHandler exit to HyperCard else if item is "Cut Card" then doMenu "Copy Card" deleteCardHandler exit to HyperCard else if item is "Paste Card" then answer "Sorry, you can't paste a card into this stack." exit to HyperCard else pass doMenu end doMenu
-- on newCardHandler if short name of this bg is "Records" then set cursor to busy send "doMenu New Card" to HyperCard put (number of this card - 2) && "of" && \ (number of cards of this bg) into bg field "Card#" makeIndexMenu mark this card tabKey else answer "Sorry, you must be in the Records section to add a new card." end if exit to HyperCard end newCardHandler
-- on deleteCardHandler if short name of this bg is "Records" then if number of cards of this bg = 1 then answer "Delete this card?" &return&return&Â "(This is currently the only record card, so it will be" \ && "replaced with a new card.)" with "Cancel" or "Delete" if it is "Cancel" then exit to HyperCard lock screen repeat with x = 1 to 11 put empty into bg field x end repeat makeIndexMenu unlock screen tabKey exit to HyperCard else answer "Are you sure you want to delete this card?" \ with "Cancel" or "Delete" if it is "Cancel" then exit to HyperCard set cursor to busy lock screen send "doMenu Delete Card" to HyperCard if the short name of this bg is not "Records" then go to previous card makeIndexMenu end if else answer "Sorry, you can't delete this card." end deleteCardHandler
At the end of the stack script are three handlers that manage menus when the stack is suspended, resumed, and closed. In HyperCard these are necessary in order to clean up the menu bar when the stack's active status changes. Because LiveCode's menus are permanent objects (they are actually buttons,) they manage themselves automatically. No additional scripting is required to show or maintain a stack's custom menu bar, so these HyperCard handlers are not needed. Completely delete from the script the suspendStack, resumeStack, and closeStack handlers.
The newCardHandler and deleteCardHandler pair also contain doMenu references. We will be changing these handlers when we move them into LiveCode menus later. You can comment them out for now.
There are a few other menu references in button scripts scattered around the stack, but they will not error unless their buttons are clicked, so we will change those after the import. Close the script editor.
The background scripts are all fine. No changes are necessary.
The idle handler. Open the script of the first card. You will see an idle handler. Comment out this handler. We will discuss idle and the play command in the next section, but for now we need to remove this handler to prevent LiveCode from erroring repeatedly when the stack opens.
Finally, compact the stack. This forces HyperCard to write a clean copy of the file to disk. Don't omit this step -- it assures a more accurate translation.
That's it. We are ready to move the stack into LiveCode.
A note about externals: If you have AddColor scripts or other calls to XCMDs or XFCNs in your own stacks, this would be the time to comment out those lines. Our sample stack has no externals, so we can skip this step. Most stacks will need additional commenting at this point in the process.