• 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
Type 1 error
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Type 1 error


  • Subject: Type 1 error
  • From: "Marc K. Myers" <email@hidden>
  • Date: Sun, 04 Feb 2001 23:26:22 -0500
  • Organization: [very little]

I wrote the following script to play with the idea of a script spawning
one-shot agents that would do their job and then delete themselves.
This one makes little alarm-clock scripts that signal at the appropriate
time and then have Finder put them in the trash.

This works fine up to a point, that point being when I tried to extend
the functionality by putting the agents in the startup items folder so
they would survive a restart and "keep on ticking". The agents quit but
when they are run again they produce a type 1 error before they execute
the first line of the script. Has anyone any idea why this is happening?

-- NOTE: Must be saved as a stay-open application

try
set theTime to ""
repeat until class of theTime is date
try
set dlgRslt to (display dialog "What time do you " & [optn-L]
"want to be beeped?" default answer "")
on error
quit
return
end try
try
set theTime to date (text returned of dlgRslt)
on error
try
display dialog "\"" & (text returned of dlgRslt) & [optn-L]
"\" can't be interpreted as a time!" with icon note
on error
quit
return
end try
end try
end repeat
if theTime < (current date) then
set theTime to theTime + (1 * days)
end if
set scriptObject to makeScript(theTime as text)
set thisScript to (path to me)
if (date string of theTime) doesn't equal [optn-L]
(date string of (current date)) then
set {od, AppleScript's text item delimiters} to [optn-L]
{AppleScript's text item delimiters, {","}}
set theText to text items 2 thru -1 of (theTime as text)
set theText to theText as text
set AppleScript's text item delimiters to od
else
set theText to (time string of theTime)
end if
set {od, AppleScript's text item delimiters} to [optn-L]
{AppleScript's text item delimiters, {":"}}
set theName to text items of theText
set AppleScript's text item delimiters to {"."}
set theName to (theName as text)
set AppleScript's text item delimiters to od
set siPath to (path to startup items folder)
tell application "Finder"
set newScript to (duplicate thisScript to siPath) as alias
set name of newScript to theName
end tell
store script scriptObject in newScript with replacing
ignoring application responses
tell application (newScript as text) to run
end ignoring
quit
on error errMsg number errNbr
error errMsg number errNbr
quit
end try


on makeScript(wakeUp)
script theBeeper
property textTime:wakeUp
property firstTime:true

on idle
try
set theTime to date textTime
set myPath to (path to me) as text
if myPath contains "trash" then
quit
return
end if
if firstTime then
set firstTime to false
return (theTime - (current date))
end if
if theTime > (current date) + 15 then
ignoring application responses
tell application "Finder" to delete file myPath
end ignoring
return 4
end if
beep 10
activate
display dialog "It is now " & [optn-L]
(time string of theTime) & [optn-L]
"." & return & return & "Time to wake " & [optn-L]
"up!" buttons {"OK"} default button 1 with icon note
ignoring application responses
tell application "Finder" to delete file myPath
end ignoring
return 4
on error errMsg number errNbr
error errMsg number errNbr
set myPath to (path to me) as text
if myPath does not contain "trash" then
ignoring application responses
tell application "Finder" to delete file myPath
end ignoring
return 4
else
quit
return
end if
end try
end idle

on quit
set myPath to (path to me) as text
if (myPath contains "trash") or [optn-L]
(myPath contains "startup items") then
set firstTime to true
continue quit
else
ignoring application responses
tell application "Finder" to delete file myPath
end ignoring
return 4
end if
end quit
end script
end makeScript

Where you see "[optn-L]", use the AppleScript continuation character,
which you get with that keyboard combination.

Marc K. Myers <email@hidden>
http://AppleScriptsToGo.com
4020 W.220th St.
Fairview Park, OH 44126
(440) 331-1074

[2/4/01 11:26:13 PM]


  • Prev by Date: Re: Metamorphosax! [was: Push for AppleScript in OS X]
  • Next by Date: Re: parent properties - [it's your breath...let's talk scope]
  • Previous by thread: Re: Metamorphosax! [was: Push for AppleScript in OS X]
  • Next by thread: How can i close the active brower?
  • Index(es):
    • Date
    • Thread