Stack with the same name loop

Mark Wieder ahsoftware at
Fri Oct 8 16:28:28 EDT 2021

On 10/8/21 8:24 AM, Bob Sneidar via use-livecode wrote:
> Where did you find this script? I am pondering adding this to my "scripts to replace when I download a new version" list.

It's in revbackscriptlibrary.livecodescript.
Here's an improved version that avoids that double cancel.

on reloadStack pStackName, pFileName
    if the filename of stack pStackName is pFileName then
       toplevel pStackName
       set the defaultStack to pStackName

       local tFilePath, tFileLongPath
       put the effective fileName of stack pStackName into tFilePath
       put tFilePath into tFileLongPath
         if tFileLongPath is empty then
             put pStackName into tFileLongPath
             put comma && pStackName & "?" after tFilePath
             put pStackName & "?" into tFilepath
         end if
       answer warning "A stack with the name"&&pStackName&&"is already 
open." & cr & "Before loading" && pFileName & ", what do you want to do 
with stack:" & cr & tFilePath with "Rename" or "Save" or "Purge" or "Cancel"
     local tAction
     put it into tAction
       if gREVSuppressMessages then
          lock messages
          send "revInsertMessageBlock" to me in 100 milliseconds
          revInternal__UnloadLibrary "revNoMessagesLibrary"
       end if

      local tLockMessages
       put the lockMessages into tLockMessages

      switch tAction
         case "Cancel"
             exit to top
         case "Rename"
             ask "Enter a name for the stack in memory"
             if it is not empty and it is not pStackName then
                 set the name of stack tFileLongPath to it
                 go stack pFileName
                 exit to top
             end if
         case "Save"
             if the filename of stack pStackName is empty then
                 revSaveAs pStackName
                 revSave pStackName
             end if
         case "Purge"
             revAOUpdateForDeleteStack pStackName
             lock messages
             delete stack pStackName
             set the lockMessages to tLockMessages
             go stack pFileName
      end switch
    end if

    if there is a stack "revApplicationOverview" then
       send "revNewStack the short name of stack pFileName" to stack 
    end if
end reloadStack

  Mark Wieder
  ahsoftware at

More information about the use-livecode mailing list