Methods
frame:MethodName(parameters)
result := aFrame:Max(a, b);The above code sends the
Max
message to aFrame
.
Sending a message requires a frame (sometimes called an object) and the name of a function, along with parameters, if any. Between the frame and the function name is a colon (:
).
The distinction between a method and a message is simple:
Display
method in many of your application template frames. Just as you would expect, the Display
method that executes depends on which frame you send the message to and the rules of inheritance.
frame.Message()
instead of frame:Message()
). We call this the off-by-one-pixel syntax error. Here is the chatty error you get:
//-- Error: "<input>", Line 1, syntax error--read '(', but wanted end-of-file, '&', ')', '*', '+', ',', '-', '.', '/', ':', ';', '<', '>', '[', ']', '}', SYMBOL, END, THEN, ELSE, ONEXCEPTION, TO, BY, UNTIL, DO, WITH, ASSIGN, AND, OR, LEQ, GEQ, EQL, NEQ, EXISTS, AMPERAMPER, DIV, MOD, LS
Just remember when you see this error to check for periods instead of colons in your messages.
An online version of Programming for the Newton using Macintosh, 2nd ed. ©1996, 1994, Julie McKeehan and Neil Rhodes.
Last modified: 1 DEC 1996