Two questions:
#1: What exactly does it mean to say:
on blah from x between y
end blah
is that the same thing as saying
on blah (x,y)
??
#2: Is it the same thing to say:
set x to blah() of me
and
set x to my blah()
thank you!
Two questions:
#1: What exactly does it mean to say:
on blah from x between y
end blah
is that the same thing as saying
on blah (x,y)
??
#2: Is it the same thing to say:
set x to blah() of me
and
set x to my blah()
thank you!
Hi Patrick,
it’s almost the same, in the second form the order of the parameters is mandatory,
in the first one each parameter is assigned to a preposition, so the order doesn’t matter
yes, it’s the same
Thanks for the reply.
Hmm… Can you explain in what instance the order of parameters would matter-- or when you would use one form over the other?
Because in my mind, I think we do something like:
set x to "hi"
set y to "bye"
and then do this:
my speak(x,y)
display dialog x
display dialog y
end speak
its the same as this:
my speak(y,x)
display dialog x
display dialog y
end speak
I mean, I get that the program operates in an order, so in one example x gets defined first, then y… and then in the other y first, then x.
But-- How does that really affect anyone, since the those variables get defined so quickly?
thank you.
it’s not the same!
set x to "hi"
set y to "bye"
speak(x, y)
on speak(x, y)
say x
say y
end speak
says first “hi” then “bye”
using this handler instead
on speak(y, x}
say x
say y
end speak
says first “bye” then “Hi”
The variables will taken exactly in the same order as they are passed in the handler call,
regardless how they are named.
I actually use the labeled parameters only, if I want to use also self-defined boolean parameters, like this write_to_file handler
on write_to_file from source into target by textClass given append:append
It can be called
write_to_file from a into b by c without append
or
write_to_file by c from a into b with append
I’m sorry… That was a typo…
I meant:
on speak(x, y)
say x
say y
end speak
and
on speak(y,x)
say x
say y
end speak
but yes, immediately after I thought about this, I screamed… Because yes obviously you have to pass variables into those, and if you did my speak(y,x), then x would just become y…
So I don’t know why I wasn’t thinking clearly!!!
Thank you.