Stack file opened message?

Bob Sneidar bobs at twft.com
Wed Jul 18 18:51:09 EDT 2012


Okay never mind I see the problem. The openStack command would have to be in a frontscript because it won't get triggered in the currently open stack containing the stack name as a stack file. Did that make sense? Still, it can be done. Insert this into a frontScript after which you can call getLastStackInfo() with one of 4 values:

empty: returns an array of all 3 of the following items
stackname: a string containing the stackname
path: the path to the stack
filename: the name of the file (minus the path)

anything else: empty

NOTE: You can get fancy with this by excluding uielements but this is just quick and dirty. 

-----insert the following into front scripts

local theLastOpenedStackName, theLastOpenedStackPath, theLastOpenedFileName

ON openStack
    put the short name of this stack into theLastOpenedStackName
    put word 6 to -1 of the long name of the target into theLastOpenedStackPath
    replace quote WITH empty in theLastOpenedStackPath
    put theLastOpenedStackPath into theLastOpenedFileName
    replace "/" WITH cr in theLastOpenedFileName
    delete line 1 to -2 of theLastOpenedFileName
    pass openStack
END openStack

FUNCTION getLastStackInfo whichParameter
   global gStackInfo
   SWITCH whichParameter
      CASE ""
         put theLastOpenedStackName into theResult["stackname"]
         put theLastOpenedStackPath into theResult["path"]
         put theLastOpenedFileName into theResult["filename"]
         break
      CASE "stackname"
         put theLastOpenedStackName into theResult
         break
      CASE "path"
         put theLastOpenedStackPath into theResult
         break
      CASE "filename"
         put theLastOpenedFileName into theResult
         break
      DEFAULT 
         put empty into theResult
   END SWITCH
   put theResult into gStackInfo
   return theResult
END getLastStackInfo

-----end of front scripts

Bob


On Jul 18, 2012, at 2:54 PM, Peter Haworth wrote:

> I haven't tried this but I suspect the target contains the stack name and
> having got that, you can get it's effective filename to get the stack file
> name.
> Pete





More information about the use-livecode mailing list