• 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: Stay Open
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Stay Open


  • Subject: Re: Stay Open
  • From: Richard 23 <email@hidden>
  • Date: Fri, 12 Jan 2001 01:02:44 -0800

>Some really dumb idle questions:

Matched by insipid uninformed answers!

>1. Do scripts with idle routines always begin with a run statement
>ie:
> on Run
> idle
> end Run

all scripts do whether explicit (on run...) or implicit. (do this
stuff...)

>2. Can you pass parameters to idle handlers
>ie:
>set x to 15

yes, and they'll be cheerfully ignored so there's not much point.

>on idle(x)
>set y to (x + 20)
>return y
>end idle

how about an equally pointless example?

-- ---------------------------------------------------------
-- Preprocessed by Convert Script 1.0d2
-- ---------------------------------------------------------
idle

idle "wow"
display dialog {"result: " & result, "Fascinating", 1, -20028, 3}

on idle x
log x's class
if not (display dialog {"x: " & x's class, {"Go Away", "OK"}, ==>
2, -16550, 2}) then quit
if x = me then
"neato mosquito"
else
3
end if
return DoTell()
end idle


on DoTell()
set theMsg to result
display dialog {"Returning: " & result, "Oh", 1, -20012, 3}
return theMsg
end DoTell


on display dialog {theMsg, theButtons, theDefault, theIcon, theDelay}
if theDefault's class = integer then set theDefault to ==>
item theDefault of (theButtons as list)
continue display dialog theMsg buttons theButtons ==>
default button theDefault with icon theIcon giving up after
theDelay
return result's gave up or result's button returned = theDefault
end display dialog
-- ---------------------------------------------------------

ASIDE: when calling idle explicitly, the return value doesn't seem to
affect the idle delay, but if returning a string for example when the
idle handle is called automatically it modifies the idle delay, possibly
resetting to a default value...dunno. I didn't want to wait 30 seconds!

when the idle handler is called explicitly the class of the
passed argument is displayed, otherwise the class is "script".

About command handlers and the direct parameter
-----------------------------------------------

This is interesting to note when writing command handlers.
Every handler/command has a direct parameter. Some are not
used, but whenever a command handler is called without a direct
parameter the calling script is passed instead (by reference).

For example:

on offset of subStr in theStr
...
end offset

there is an unused direct parameter here before the "of" parameter.
I have used that to redefine offset to return an indexed offset
like this:

on offset theIdx of subStr in theStr
if theIdx = me then -- probably safer as if theIdx's class = script...
-- generate a normal result
...
else
-- generate the indexed result
end if
end offset

Not really on topic but still useful sometimes...

>
>3. Can an idle handle return any variable besides the time it should idle?

Yeah but as I already stated, a non-numeric value blows your idle delay.

>Thanks
>xandra


  • Prev by Date: Re: Script Application handles an event, then quits
  • Next by Date: Re: Mac OS 9.1 Standard Additions OSAX
  • Previous by thread: Re: Stay Open
  • Next by thread: Bounds?
  • Index(es):
    • Date
    • Thread