• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Simple Repeat until loop problem
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Simple Repeat until loop problem


  • Subject: Re: Simple Repeat until loop problem
  • From: "Nigel Garvey" <email@hidden>
  • Date: Thu, 22 Dec 2005 20:48:14 +0000

Bill Cheeseman wrote on Thu, 22 Dec 2005 12:43:22 -0500:

>on 2005-12-22 12:24 PM, Maccin at email@hidden wrote:
>
>> repeat until (busy of window numberOfWindows) is false
>> --stay in this loop until the script finishes
>> end repeat
>
>> This script should stay in the repeat until loop while ssh is running.
>>  When ssh quits the loop should end and the "Process Finished" dialog
>> should appear.  However, when I run this script it will go through the
>> repeat look straight to the dialog-box.  This happens even when I
>> change the bool to false.  Any suggestions would be appreciated.
>
>Last time I looked, a repeat block with nothing in it did not repeat. That
>would certainly explain what you're seeing when you set the condition to
>'false'.

Empty repeat blocks certainly do repeat. Only if the end condition is
already met do they not do so. (Or if there's an error while checking the
end condition, of course!)


Maccin wrote on Thu, 22 Dec 2005 12:24:32 -0500:

>tell application "Terminal" to count windows
>set numberOfWindows to (result + 1) as number -- do script will
>automatically create a new --window so we need to add one to get the
>reference
>--display dialog ("There are " & numberOfWindows & " windows open.")
>
>tell application "Terminal"
>	do script "ssh " & clientUserName & "@serverGoesHere; exit"
>
>	repeat until (busy of window numberOfWindows) is false
>		--stay in this loop until the script finishes
>	end repeat
>
>	display dialog ("Process Finished")
>end tell

The problem's the window numbering system. When a new window opens, it
becomes the new window 1 and the others all move back one. Your script's
actually checking the 'busy' of the rearmost window. If you simply check
the 'busy' of window 1, you should be OK -- although inserting a short
delay just before the repeat would allow the Terminal a little extra time
to create the window for the 'do script' command and set its 'busy' status.

Another idea, if it suits your purposes, is to run the script in the
existing front window, which would save another from opening:

  tell application "Terminal"
    do script "ssh " & clientUserName & "@serverGoesHere; exit" in window 1

    delay 1 -- say
    repeat until (busy of window numberOfWindows) is false
      --stay in this loop until the script finishes
    end repeat

    display dialog ("Process Finished")
  end tell

NG

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Simple Repeat until loop problem
      • From: "Nigel Garvey" <email@hidden>
    • Re: Simple Repeat until loop problem
      • From: "Nigel Garvey" <email@hidden>
  • Prev by Date: Re: Finding lines containing foo in a file
  • Next by Date: Re: Simple Repeat until loop problem
  • Previous by thread: Re: Simple Repeat until loop problem
  • Next by thread: Re: Simple Repeat until loop problem
  • Index(es):
    • Date
    • Thread