• 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: Getting a script to run itself recursively
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Getting a script to run itself recursively


  • Subject: Re: Getting a script to run itself recursively
  • From: Matt Deatherage <email@hidden>
  • Date: Sun, 27 May 2007 03:19:36 -0500

On 5/27/07 at 2:17 AM, Jim Witte <email@hidden> wrote:

set sPath to the path of (item 1 of the document of me)
-- 'path of me' strangely enough returns BOTH the script file path,
-- AND the path to 'Standard Additions' - presumably because
-- I use it here, even though it is definitely not what I'd think of as
-- 'me' in this context (coming from a HyperTalk/Transcript  bkg
-- that is..)

display dialog sPath
display dialog "Contune?" buttons {"Yes", "No"}
if button returned of the result is "Yes" then
run script ("ilamp:Users:billw:Destop:Untitled.scpt") as file
-- run script sPath --as file
end if

Dude, I don't know what environment or terminology you're using, but
this is foreign to me. "path of me" is a syntax error. "path to me" is
a scripting addition, but it returns an alias, not a string. Given all
that, I can't possibly imagine what's really happening where you're
trying to write this script.


Ideally, the script should tell the computer to run itself, then tell
the computer to sleep, and then (when it wakes up again) end the FIRST
instance of the script..

...which would mean that if you manually awaken the computer before your
alarm time, your recursive script will immediately put it back to sleep
for you. Do you *never* get up ahead of your alarm?


I think you'll have better luck if you tell the computer to sleep until
your alarm time. When it wakes, I think you get control back, so you
can check the time. If the time is between the time you set the alarm
yet before the alarm should go off, display a dialog box for 10-15
seconds asking if you really want to wake up, and if not, go back to
sleep. That's just a simple loop and avoids recursion.


You can read more about scheduling wake and sleep times here, if you
haven't already got that down:
<http://macscripter.net/articles/468_0_10_0_C/>

(My iMac flat panel has a funny habit of waking itself up for unknown
reasons..  The wake code is 0x0040 in Console, if that means anything
to anyone)

Not to me - I'd need to see more info, but my first guess would be "wake
on modem ring" or "wake on LAN" set in the Energy Saver preference pane.
0x0040 is often the USB ID of the keyboard or keyboard controller, too,
so it might log that way if you have a cat or something. For all I know,
0x0040 means "hey, wait a minute, there's no 'path of' command..."


--Matt
--
Matt Deatherage                              <email@hidden>
GCSF, Incorporated                      <http://www.macjournals.com>

"I like life.  It's something to do."  -- Ronnie Shakes%


_______________________________________________ Do not post admin requests to the list. They will be ignored. AppleScript-Users mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden
References: 
 >Getting a script to run itself recursively (From: Jim Witte <email@hidden>)

  • Prev by Date: Getting a script to run itself recursively
  • Next by Date: Re: Getting a script to run itself recursively
  • Previous by thread: Getting a script to run itself recursively
  • Next by thread: Re: Getting a script to run itself recursively
  • Index(es):
    • Date
    • Thread