On 10/7/21 1:08 PM, Mark Wieder via use-livecode wrote:
How about a fourth option to rename the stack in memory and continue?

...replying to myself...
I fixed reloadStack to allow a rename and be a little less scary.
I just edited the livecodescript file on disk and it so far seems to work in all my tests.

on reloadStack pStackName, pFileName
   if the filename of stack pStackName is pFileName then
      toplevel pStackName
   else
      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
        else
            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 reloadStack
        case "Rename"
            ask "rename the stack in memory to"
            if it is not empty and it is not pStackName then
                set the name of stack tFileLongPath to it
            end if
            set the lockMessages to tLockMessages
            go stack pFileName
            break
        case "Save"
         if the filename of stack pStackName is empty then
            revSaveAs pStackName
         else
            revSave pStackName
         end if
        case "Purge"
         revAOUpdateForDeleteStack pStackName
         lock messages
         delete stack pStackName
         set the lockMessages to tLockMessages
         go stack pFileName
            break
    end switch
   end if

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

--
 Mark Wieder
 ahsoftw...@gmail.com

_______________________________________________
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode

Reply via email to