Cloning cards

Richard Gaskin ambassador at fourthworld.com
Thu Nov 18 10:54:32 EST 2010


Joe Lewis Wilkins wrote:

 > My dilemma, now, is that this sub-stack is already part of the
 > standalone, so splitting it off as another stack file may not
 > be so easy. OTOH, it may also solve an issue I now have
 > communicating between that "sub-stack" and the main stack in
 > the standalone.

Maybe not so bad - consider trying this:

Rename the existing substack something like "SubstackNameTEMPLATE", when 
add this when you need to create a savable document:

   -- Make the savable stack:
   clone stack "SubstackNameTEMPLATE"
   set the name of it to "SubstackName"
   -- Now to save it in some writable location:
   set the filename of it to MyDataPath()
   save stack "SubstackName"

In a central library you can use this handy function to find the path to 
the file for saving or opening:

function MyDataPath
    switch the platform
    case "MacOS"
      put specialFolderPath("asup") into tPath
      break
    case "Win32"
      put specialFolderPath(26) into tPath
      break
    case "Linux"
      put specialFolderPath("home")&"/Documents" into tPath
    end switch
    --
    put "/MyAppName/" after tPath
    if there is not a folder tPath then
      create folder tPath
      if the result is not empty then
         answer "Error: "& the result
         exit to top
      end if
    put "MyDocumentName.myExtension" after tPath
    return tPath
end MyDataPath


The above is off-the-cuff and untested, but I've written similar 
handlers often so hopefully it will be at least mostly working and 
somewhat helpful. :)

--
  Richard Gaskin
  Fourth World
  LiveCode training and consulting: http://www.fourthworld.com
  Webzine for LiveCode developers: http://www.LiveCodeJournal.com
  LiveCode Journal blog: http://LiveCodejournal.com/blog.irv



More information about the Use-livecode mailing list