Loading ...
Sorry, an error occurred while loading the content.

Re: WPMac stalls during startup

Expand Messages
  • em315
    ... Also from various reports on emaculation.com of emulators that simply stopped working. There are plenty of threads where the moderators ask for the
    Message 1 of 15 , Jan 9, 2012
    • 0 Attachment
      --- In wordperfectmac@yahoogroups.com, "em315" <em315@...> wrote:
      >
      > --- In wordperfectmac@yahoogroups.com, "John R" <johnrethorst@> wrote:
      >
      > > > SheepShaver is notoriously delicate and easy to break. A repair-permissions shouldn't hurt it
      > >
      >
      > I was writing from experience;

      Also from various reports on emaculation.com of emulators that simply stopped working. There are plenty of threads where the moderators ask for the contents of the prefs file in the hope of sorting it out.
    • John R
      ... The script below tests different ways to exit an idle handler. The Quit command quits the whole script, but only after the handler completes. Error number
      Message 2 of 15 , Jan 12, 2012
      • 0 Attachment
        --- In wordperfectmac@yahoogroups.com, "John R" <johnrethorst@...> wrote:

        > It may be that you quit the app in the middle of the idle handler,
        > which launches or activates WP more than once. Let me see what
        > I can figure out.

        The script below tests different ways to exit an idle handler. The Quit command quits the whole script, but only after the handler completes. Error number -128 and Return exit the handler, but it runs again after 30 seconds (or, if a number follows Return, that number of seconds). If the idle handler tells WP to run (or launch or activate), that command will still execute.

        So you could do something like:

        tell application "Finder"
        if creator type of processes contains "WPC2"
        --do something
        else
        tell me to quit
        return
        end tell

        -----------
        test script:


        global biff

        on run
        set biff to choose from list {"Quit", "Error number -128", "Return"} with prompt ¬
        "Choose what to do in the idle handler:" with multiple selections allowed and empty selection allowed
        if biff = false then
        quit
        return
        end if
        end run

        on idle
        display dialog "1" giving up after 1
        display dialog "2" giving up after 1
        display dialog "3" giving up after 1

        --**********

        if biff contains "Quit" then quit

        if biff contains "Error number -128" then error number -128

        if biff contains "Return" then return

        --**********

        display dialog "4" giving up after 1
        display dialog "5" giving up after 1
        display dialog "6" giving up after 1

        return 2
        end idle
      • em315
        ... Here s where it becomes clear that you know what you re doing and I don t. I simply don t know what I should be doing with the script that you posted. I m
        Message 3 of 15 , Jan 12, 2012
        • 0 Attachment
          > --- In wordperfectmac@yahoogroups.com, "John R" <johnrethorst@> wrote:
          > The script below tests different ways to exit an idle handler. The Quit command quits the whole script, but only after the handler completes. Error number -128 and Return exit the handler, but it runs again after 30 seconds (or, if a number follows Return, that number of seconds). If the idle handler tells WP to run (or launch or activate), that command will still execute.

          Here's where it becomes clear that you know what you're doing and I don't. I simply don't know what I should be doing with the script that you posted. I'm sorry to be so dense, but any suggestions would be very helpful.

          Meanwhile, for what it's worth, here's the on idle loop in my background script. It's probably stolen mostly from yours. Again, the mystery is why sometimes - but only sometimes - when I tell the Mac OS to quit (and thus quit SheepShaver), and my background script is running in the background, WP starts up and blocks the shutdown. Of course, I can't make it do this today, but it's happened now and then in the past.

          ------------

          on idle
          if alreadyOpen is 1 then
          tell application "Finder"
          if exists (some process whose name contains "Corel WordPerfect") then
          tell application "Corel WordPerfect" to activate
          set alreadyOpen to 0
          end if
          end tell
          end if
          try
          tell application "Finder" to set transferDoc to transferFile as alias
          on error
          return 0.5
          end try

          set tid to text item delimiters
          set text item delimiters to return

          set filePaths to (read transferDoc)
          set fileList to text items of filePaths

          tell application "Corel WordPerfect"
          launch
          --Do Script "On Startup"
          if fileList is "" then
          else
          repeat with i from 1 to ((count items in fileList) - 1)
          try
          set thisFile to (item i of fileList as string)
          open (thisFile as alias)
          on error
          display dialog "I could not open "" & thisFile & ""." buttons ¬
          {"OK"} default button 1 with icon caution
          exit repeat
          end try
          end repeat
          end if
          end tell

          try
          deleteFile transferDoc -- Jon's Commands
          on error
          tell application "Finder" to delete transferDoc
          end try

          set text item delimiters to tid
          set fileList to ""
          return 0.5
          end idle

          --------------

          Does this look as if there's something obviously wrong with it?
        • em315
          I ve experimented a bit with this, and I think I see what I should do with this, but I m not entirely sure. So, to confirm - should I insert this code into my
          Message 4 of 15 , Jan 16, 2012
          • 0 Attachment
            I've experimented a bit with this, and I think I see what I should do with this, but I'm not entirely sure.

            So, to confirm - should I insert this code into my background script, select one of the options, and see which one most reliably avoids restarting WP? I'm not sure I know how to fit this in. Any advice would be welcome!

            --- In wordperfectmac@yahoogroups.com, "John R" <johnrethorst@...> wrote:
            >
            >
            >
            > --- In wordperfectmac@yahoogroups.com, "John R" <johnrethorst@> wrote:
            >
            > > It may be that you quit the app in the middle of the idle handler,
            > > which launches or activates WP more than once. Let me see what
            > > I can figure out.
            >
            > The script below tests different ways to exit an idle handler. The Quit command quits the whole script, but only after the handler completes. Error number -128 and Return exit the handler, but it runs again after 30 seconds (or, if a number follows Return, that number of seconds). If the idle handler tells WP to run (or launch or activate), that command will still execute.
            >
            > So you could do something like:
            >
            > tell application "Finder"
            > if creator type of processes contains "WPC2"
            > --do something
            > else
            > tell me to quit
            > return
            > end tell
            >
            > -----------
            > test script:
            >
            >
            > global biff
            >
            > on run
            > set biff to choose from list {"Quit", "Error number -128", "Return"} with prompt ¬
            > "Choose what to do in the idle handler:" with multiple selections allowed and empty selection allowed
            > if biff = false then
            > quit
            > return
            > end if
            > end run
            >
            > on idle
            > display dialog "1" giving up after 1
            > display dialog "2" giving up after 1
            > display dialog "3" giving up after 1
            >
            > --**********
            >
            > if biff contains "Quit" then quit
            >
            > if biff contains "Error number -128" then error number -128
            >
            > if biff contains "Return" then return
            >
            > --**********
            >
            > display dialog "4" giving up after 1
            > display dialog "5" giving up after 1
            > display dialog "6" giving up after 1
            >
            > return 2
            > end idle
            >
          • John R
            ... The more I look at this, the less I can figure out. Running my earlier test script a few times, I saw that an error number -128 in an idle handler will
            Message 5 of 15 , Jan 18, 2012
            • 0 Attachment
              --- In wordperfectmac@yahoogroups.com, "em315" <em315@...> wrote:

              > the mystery is why sometimes - but only sometimes - when I tell the Mac OS to quit (and thus quit SheepShaver), and my background script is running in the background, WP starts up and blocks the shutdown.

              The more I look at this, the less I can figure out. Running my earlier test script a few times, I saw that an error number -128 in an idle handler will sometimes not exit the handler. But you're not doing that here; all I can think of is that even if there isn't a transferDoc file in the expected folder, the handler continues to execute and WP launches. I'd think it's not necessary to launch WP; if the script tells the program to open a file, that would run the program. I'm sorry that I can't see anything more useful at this point.

              FWIW here's a few much less important questions and suggestions, prefaced by a "--**" on each line.


              on idle
              if alreadyOpen is 1 then
              tell application "Finder"
              if exists (some process whose name contains "Corel WordPerfect") then
              tell application "WordPerfect" to activate
              set alreadyOpen to 0
              end if
              end tell
              end if

              --** instead of <if exists some process whose name contains> (or process 1 whose name contains), why not
              --** do <if creator type of processes contains "WPC2">, since the user may have changed the name of the app,

              try
              tell application "Finder" to set transferDoc to transferFile as alias
              on error
              return 0.5
              end try

              set tid to text item delimiters
              set text item delimiters to return

              set filePaths to (read transferDoc)
              set fileList to text items of filePaths

              tell application "WordPerfect"
              launch
              --Do Script "On Startup"

              --** the automatic script needs to be named <OnStartup> without a space to work as such in WP..
              --** The launch command starts WP without running the script. Nothing wrong with either way,
              --** but what's the advantage of not running the script?

              if fileList is "" then
              else

              --** you could do <if fileList is not "" then> but there should be content in fileList at this point,
              --** unless transferDoc for some reason has no text in it that could be file paths.
              --** Probably best to have this check though.

              repeat with i from 1 to ((count items in fileList) - 1)
              try
              set thisFile to (item i of fileList as string)
              open (thisFile as alias)
              on error
              display dialog "I could not open "" & thisFile & ""." buttons ¬
              {"OK"} default button 1 with icon caution
              exit repeat
              end try
              end repeat
              end if
              end tell

              try
              deleteFile transferDoc -- Jon's Commands
              on error
              tell application "Finder" to delete transferDoc
              end try

              set text item delimiters to tid
              set fileList to ""
              return 0.5
              end idle
            • em315
              Many thanks for this. Adding the On Startup script was my mistake - I didn t know there was an OnStartup macro that launched automatically on startup. So
              Message 6 of 15 , Jan 19, 2012
              • 0 Attachment
                Many thanks for this. Adding the "On Startup" script was my mistake - I didn't know there was an "OnStartup" macro that launched automatically on startup. So may I assume I'm right in thinking that there's no need to specify that OnStartup should run, because it runs anyway?

                I've made that change, and have also changed the part that tests for the process - I now use your method of checking for the process that contains WPC2.

                I didn't (yet) change from launching WP and opening the file to simply opening the file (presumably by telling application "Finder" to open it), but will do so later. Meanwhile, I've prepared the slightly revised version for uploading and will do so today.

                Will experiment with the change from launch-WP-and-open to just open later and will add then when I'm sure it works.

                Thank you again for this. I don't actually use this - I use WPDOS - but I enjoy putting this together as a mental exercise and public service.



                --- In wordperfectmac@yahoogroups.com, "John R" <johnrethorst@...> wrote:
                >
                > --- In wordperfectmac@yahoogroups.com, "em315" <em315@> wrote:
                >
                > > the mystery is why sometimes - but only sometimes - when I tell the Mac OS to quit (and thus quit SheepShaver), and my background script is running in the background, WP starts up and blocks the shutdown.
                >
                > The more I look at this, the less I can figure out. Running my earlier test script a few times, I saw that an error number -128 in an idle handler will sometimes not exit the handler. But you're not doing that here; all I can think of is that even if there isn't a transferDoc file in the expected folder, the handler continues to execute and WP launches. I'd think it's not necessary to launch WP; if the script tells the program to open a file, that would run the program. I'm sorry that I can't see anything more useful at this point.
                >
                > FWIW here's a few much less important questions and suggestions, prefaced by a "--**" on each line.
                >
                >
                > on idle
                > if alreadyOpen is 1 then
                > tell application "Finder"
                > if exists (some process whose name contains "Corel WordPerfect") then
                > tell application "WordPerfect" to activate
                > set alreadyOpen to 0
                > end if
                > end tell
                > end if
                >
                > --** instead of <if exists some process whose name contains> (or process 1 whose name contains), why not
                > --** do <if creator type of processes contains "WPC2">, since the user may have changed the name of the app,
                >
                > try
                > tell application "Finder" to set transferDoc to transferFile as alias
                > on error
                > return 0.5
                > end try
                >
                > set tid to text item delimiters
                > set text item delimiters to return
                >
                > set filePaths to (read transferDoc)
                > set fileList to text items of filePaths
                >
                > tell application "WordPerfect"
                > launch
                > --Do Script "On Startup"
                >
                > --** the automatic script needs to be named <OnStartup> without a space to work as such in WP..
                > --** The launch command starts WP without running the script. Nothing wrong with either way,
                > --** but what's the advantage of not running the script?
                >
                > if fileList is "" then
                > else
                >
                > --** you could do <if fileList is not "" then> but there should be content in fileList at this point,
                > --** unless transferDoc for some reason has no text in it that could be file paths.
                > --** Probably best to have this check though.
                >
                > repeat with i from 1 to ((count items in fileList) - 1)
                > try
                > set thisFile to (item i of fileList as string)
                > open (thisFile as alias)
                > on error
                > display dialog "I could not open "" & thisFile & ""." buttons ¬
                > {"OK"} default button 1 with icon caution
                > exit repeat
                > end try
                > end repeat
                > end if
                > end tell
                >
                > try
                > deleteFile transferDoc -- Jon's Commands
                > on error
                > tell application "Finder" to delete transferDoc
                > end try
                >
                > set text item delimiters to tid
                > set fileList to ""
                > return 0.5
                > end idle
                >
              • John R
                ... if WP is not running: tell application WordPerfect to activate -- runs OnStartup, opens new document, brings app to front tell application WordPerfect
                Message 7 of 15 , Jan 23, 2012
                • 0 Attachment
                  --- In wordperfectmac@yahoogroups.com, "em315" <em315@...> wrote:

                  > So may I assume I'm right in thinking that there's no need to specify that OnStartup should run, because it runs anyway?

                  if WP is not running:

                  tell application "WordPerfect" to activate
                  --> runs OnStartup, opens new document, brings app to front

                  tell application "WordPerfect" to run
                  --> runs OnStartup, opens new document, does not bring app to front

                  tell application "WordPerfect" to launch
                  --> loads app into memory but doesn't do anything else

                  If WP is running, the launch and run commands do nothing; the activate command brings the app to the front.

                  > Thank you again for this. I don't actually use this - I use WPDOS - but I enjoy putting this together as a mental exercise and public service.

                  It's a great public service. Thank you.

                  John R.
                • em315
                  Thank you for this - it lets me sort out my script a bit more. I ll upload an improved version by the morning. The new version adds one more feature. It
                  Message 8 of 15 , Jan 23, 2012
                  • 0 Attachment
                    Thank you for this - it lets me sort out my script a bit more. I'll upload an improved version by the morning.

                    The new version adds one more feature. It occurred to me that it might be useful to shutdown SheepShaver in an orderly way by running a script in OS X that would tell SheepShaver to shut down.

                    So I've written a script that will do exactly that with the WPMacApp, provided that the user hasn't quit the script that runs in the background in SheepShaver when it's running. A copy of the script is stored inside the WPMacApp. (Show Package Contents ->Resources->Files and copy the ShutdownWPMacApp application somewhere else.) When you run the ShutdownWPMacApp application in OS X, a few seconds later, the WPMacApp itself will shut down. All this, of course, is based on your method of using AppleScript to communicate between OS X and SheepShaver.

                    --- In wordperfectmac@yahoogroups.com, "John R" <johnrethorst@...> wrote:
                    >
                    > --- In wordperfectmac@yahoogroups.com, "em315" <em315@> wrote:
                    >
                    > > So may I assume I'm right in thinking that there's no need to specify that OnStartup should run, because it runs anyway?
                    >
                    > if WP is not running:
                    >
                    > tell application "WordPerfect" to activate
                    > --> runs OnStartup, opens new document, brings app to front
                    >
                    > tell application "WordPerfect" to run
                    > --> runs OnStartup, opens new document, does not bring app to front
                    >
                    > tell application "WordPerfect" to launch
                    > --> loads app into memory but doesn't do anything else
                    >
                    > If WP is running, the launch and run commands do nothing; the activate command brings the app to the front.
                    >
                    > > Thank you again for this. I don't actually use this - I use WPDOS - but I enjoy putting this together as a mental exercise and public service.
                    >
                    > It's a great public service. Thank you.
                    >
                    > John R.
                    >
                  Your message has been successfully submitted and would be delivered to recipients shortly.