Fourth World Logo Fourth World Media Corporation
  Embassy Services Products Resources   About Fourth World Contact  

IncWell Logo

SuperCard FAQ

4W Logo

How can I create a "Save As" item for my project?

To create a "Save As" menu item, we will need to create a copy of the document project in question under a new name, close the current one, and open the new one, just like us Mac folks have come to expect.

SuperTalk provides the "ask file" command, which will present the standard "put file" dialog, and will return the name of this new file in the global variable "it".

The Xtend project includes an XCMD called "CopyFile", which will take care of the file copying portion of this task.

With these two parts, you have pretty much all you need to pull this off - here they are together in an example script which you can use in a menu item in your File menu titled "Save As" (remember to copy the "CopyFile" XCMD to your project):

on itemSelect
end ItemSelect

on SaveAs
-- Get new file name:
ask file "Save this file as:" with the short name of the topWindow
if it is empty then exit to SuperCard
put it into tNufileName

set the cursor to watch

-- Get current file name to pass to the external:
put value(last word of the long name of this proj)
into tOldFileName

-- Make sure things are saved and compacted:

-- Copy the file:
close this wd
CopyFile tOldFileName, tNewFileName
if line 1 of the result is false then -- Error checking
answer line 2 of the result
exit to SuperCard
end if

-- Open the new file:
open proj tNewFileName

end SaveAs