Parameters vs. functions -- I don't get it
Posted: Wed Nov 01, 2006 7:14 pm
Maybe a few kind souls will educate me just a tad, or suggest a source for a concise explanation.
From my self-taught hyperCard days, I learned a little about parameters. If a handler called another handler... for example
On thisHandler
put something into x
put something else into y
put anotherthing into x
thatHandler x,y,y
end thisHandler
I could send variables x,y and z to another handler, without having to bother with declaring x y and z as globals and then cleaning them up when I was done with them.
That's all I know about parameters. Apparently there's more to parameters than this, though. For example,
On linkClicked theText
blah
blah
blah
end linkClicked
I've learned by doing that "theText" is an arbitrary variable name. Apparently, "on linkClicked thetext" means:
on linkClicked
get some something that gets sent along with the command "linkClicked"
put it into a variable named theText
use that variable as a parameter with the linkClicked command
end linkClicked
This also suggests that there is no essential difference between a command and a handler. A command seems simply to be a handler defined by RR, instead of defined by the user. Is that true?
Apparently, many standard commands send some kind of parameter -- possibly all commands. I dunno. I've learned this by trial and error, also
If I make a button with the script
on mouseUp anyOldParameter
answer anyOldParameter
end mouseup
I get an answer of "1" when I click on the mouse. I didn't know what this parameter is supposed to tell me until one minute ago, when I found it in the documentation under mouseUp. Surprise!
But then there are functions.
If I put "mary had a little lamb" into a field, lock the field and put
on mouseUp aParameter
answer aParameter
end mouseup
and click on the field, my answer is "1"
On the other hand, if the script says
on mouseUp
answer the mouseChunk
end mouseUp
My answer is something like "char 12 to 14 of field 48"
I guess the mouseChunk is a function. I don't see any mention of the mouseChunk function in the documentation for mouseUp. I can look it up in the docs, if I know it exists. Otherwise, how would I know about it? I guess I could read about every native function, but it seems like there are hundreds.
So, it seems like one or more functions and/or one or more parameters are associated with at least some commands, and possibly every command.
I've known about "the target". I guess that's a function. I've just used it by rote.
Was hyperCard the same way, in all these respects?
I've learned a few things in the process of composing this query. But I have no big-picture idea what parameters and functions are assocated with what commands. Maybe the documentation does mention the parameter or parameters sent with every command. I hadn't noticed before.
I could spend a long, long time looking up parameters sent with every command I know, and even more time looking up functions associated with every command I know. And I wouldn't remember all of that.
Is there some kind of chart that summarizes all of this? You know -- the command in column 1, parameter(s) sent with command in column 2, all functions associated with that command in column three? Something like that? I guess it would have to be hyperlinked so I could find out what information the parameters and functions contain, by clicking on them. That would be quite handy, if it exists.
I still don't get the difference between a parameter and a function when associated with a standard command. Why is the number of the mouse button clicked a parameter, whereas the mouseChunk is a function? It seems like it could just as easily be the other way around.
I'm going to look again at Danny Goodman's HC book and Dan's RR book. Maybe it's all in there and I just didn't absorb it when I studied them.
The reader is probably scratching his/her head, wondering how in the world to reply to this messy comment/query. Miscellaneous comments, attempts to educate, and directions to sources, even if minimal, would all be appreciated.
I wonder how highly skilled RR users learn all of this. I thought I knew a few things about scripting. Turns out I don't know hardly nothin.
Tim
(feeling foolish at the moment)
From my self-taught hyperCard days, I learned a little about parameters. If a handler called another handler... for example
On thisHandler
put something into x
put something else into y
put anotherthing into x
thatHandler x,y,y
end thisHandler
I could send variables x,y and z to another handler, without having to bother with declaring x y and z as globals and then cleaning them up when I was done with them.
That's all I know about parameters. Apparently there's more to parameters than this, though. For example,
On linkClicked theText
blah
blah
blah
end linkClicked
I've learned by doing that "theText" is an arbitrary variable name. Apparently, "on linkClicked thetext" means:
on linkClicked
get some something that gets sent along with the command "linkClicked"
put it into a variable named theText
use that variable as a parameter with the linkClicked command
end linkClicked
This also suggests that there is no essential difference between a command and a handler. A command seems simply to be a handler defined by RR, instead of defined by the user. Is that true?
Apparently, many standard commands send some kind of parameter -- possibly all commands. I dunno. I've learned this by trial and error, also
If I make a button with the script
on mouseUp anyOldParameter
answer anyOldParameter
end mouseup
I get an answer of "1" when I click on the mouse. I didn't know what this parameter is supposed to tell me until one minute ago, when I found it in the documentation under mouseUp. Surprise!
But then there are functions.
If I put "mary had a little lamb" into a field, lock the field and put
on mouseUp aParameter
answer aParameter
end mouseup
and click on the field, my answer is "1"
On the other hand, if the script says
on mouseUp
answer the mouseChunk
end mouseUp
My answer is something like "char 12 to 14 of field 48"
I guess the mouseChunk is a function. I don't see any mention of the mouseChunk function in the documentation for mouseUp. I can look it up in the docs, if I know it exists. Otherwise, how would I know about it? I guess I could read about every native function, but it seems like there are hundreds.
So, it seems like one or more functions and/or one or more parameters are associated with at least some commands, and possibly every command.
I've known about "the target". I guess that's a function. I've just used it by rote.
Was hyperCard the same way, in all these respects?
I've learned a few things in the process of composing this query. But I have no big-picture idea what parameters and functions are assocated with what commands. Maybe the documentation does mention the parameter or parameters sent with every command. I hadn't noticed before.
I could spend a long, long time looking up parameters sent with every command I know, and even more time looking up functions associated with every command I know. And I wouldn't remember all of that.
Is there some kind of chart that summarizes all of this? You know -- the command in column 1, parameter(s) sent with command in column 2, all functions associated with that command in column three? Something like that? I guess it would have to be hyperlinked so I could find out what information the parameters and functions contain, by clicking on them. That would be quite handy, if it exists.
I still don't get the difference between a parameter and a function when associated with a standard command. Why is the number of the mouse button clicked a parameter, whereas the mouseChunk is a function? It seems like it could just as easily be the other way around.
I'm going to look again at Danny Goodman's HC book and Dan's RR book. Maybe it's all in there and I just didn't absorb it when I studied them.
The reader is probably scratching his/her head, wondering how in the world to reply to this messy comment/query. Miscellaneous comments, attempts to educate, and directions to sources, even if minimal, would all be appreciated.
I wonder how highly skilled RR users learn all of this. I thought I knew a few things about scripting. Turns out I don't know hardly nothin.
Tim
(feeling foolish at the moment)