On Oct 21, 2010, at 2:11 PM, Robert Poland wrote:
On Oct 21, 2010, at 11:45 AM, Deivy Petrescu wrote:
On Oct 21, 2010, at 9:28 AM, Robert Poland wrote:
Thanks Brian,
But the question was directed to Smile not Script Editor.
On Oct 21, 2010, at 7:21 AM, Brian Christmas wrote:
G'day Robert
Works fine for me, using 10.6.4 and the 'run' button in script editor
Regards
Santa
global a
set a to (short date string of (current date))
my thisTime()
on thisTime()
display dialog a
end thisTime
Bob,
It works as expected in Smile.
It will not work in Smile's terminal because of the way Smile's terminal is set.
Each line can be run independently.
If you run the script you posted in Smile's terminal the way you posted it, you will get an error, "thisTime() blah blah"
This because thisTime() is called before being defined.
So if you run
on thisTime()
display dialog a
end thisTime
before the script, then it kinds of get dissociated from the script and it will not know that a and a are the same a.... :)
You can run in Script mode however.
Deivy Petrescu
email@hidden
Deivy,
ALL combinations seem to run without a problem.
It does not run here in terminal.
And it certainly it would give you more errors if you run it in the order you wrote, that is the call to the handler before the handler.
However, you are right. I did not understand the original question.
Answers below
The question is why when I validate the scripts in script mode or terminal mode do I get the two errors.
-- Undefined variables:
show window "untitled 3" selection {102, 103} -- undefined var: a
-- display dialog a
You are getting this message because "a" is not defined in the handler.
If you want to get rid of this message, then add
global a
to the top of your handler.
----------------------------------------------------
-- Unused variables:
show window "untitled 3" selection {14, 15} -- unused var: a
-- set a to (short date string of (current date))
You are getting this message because "a" is only used once in this script.
In its definition. Therefore, it is telling you may be you don't really need this "a" variable.
Actually we could point out to Emmanuel that, if there is a global a, then this message should not show up.
Robert Poland - Fort Collins, CO
Hope this clarifies.
Deivy