Here's a handler that, when its stack is opened, says either "Good Morning" or
"Good Afternoon", whichever is appropriate:
On OpenStack
global openfirst
if openfirst <> "yes" then
get the time
if it contains "PM" then
play SoundName --plays "Good afternoon sound" if it is PM
else
if it contains "AM" then
play soundName --plays "Good afternoon sound" if it is PM
end if
end if
put "yes" into openfirst
end if
end OpenStack
The reason you declare you "global" up front (in addition to the fact that
in all programming you must declare your globals first before using them)
is so that when the user leaves the stack and re-enters it, it won't
execute the script "from scratch" all over again.
This article is adapted from the Claris Tech Info database.