TOP | UP: Reference | NEXT: Verbs |
Spaces between names and operators and punctuation are largely optional in UserTalk. Clearly one cannot run keywords and names together, since this makes a different name; but otherwise spacing is pretty much a matter of style. It makes no difference which of these one says:
on myHandler(x=1,y=2)
« a bit cramped, I think
on myHandler ( x = 1, y = 2 )
« I like this better
on myHandler ( x = 1 , y = 2 )
« legal, but no one writes this way
Blank lines in a script are also perfectly acceptable, and are often used to accentuate the script's structure; they do not have any meaning. Sometimes you are required to have at least a blank line, because a loop's bundle cannot be completely empty. Suppose, for instance, you want to pause until the mouse is clicked. It is illegal to say:
msg ("Click the mouse, please...")
while not mouse.button()
« tread water (this is a comment line)
msg ("You clicked it!")
This causes a compile error. The while loop must contain at least one actual command line, even if it is blank; it cannot consist of just a comment line.
Capitalization is not significant in object names. But capitalization is significant in string comparisons. This can be confusing when one is using string comparison in a context where capitalization is normally not significant. For instance, suppose we wish to know whether the currently selected database entry is workspace.myEntry. If we say:
if table.getcursor() == "workspace.myentry"
the test will fail; we have caused implicit coercion of table.getcursor()'s result to a string, and are performing string comparison. On the other hand, if we say
if table.getcursor() == @workspace.myentry
the test will succeed. To construct a case-insensitive string match, call string.lower() on both sides of the comparison:
if string.lower("MyString") == string.lower("mysTring")
« succeeds
Separates parameters in a verb call and in a handler definition (on line). Separates names in the parentheses form of a local declaration. Separates domain names in a with statement. Separates items in lists and in records.
In a numeric literal, the decimal point. Separates elements in a reference to a table entry. Separates container from contained in an object specifier in object-model syntax.
In a record literal, separates names from values. In a verb call, separates explicit parameter names from values. Separates name from value in an index of an object specifier in object-model syntax.
Separates commands when a script is in a text context (as opposed to a script object); a single line of a script in a script object counts as a text context. (See Chapter 4, What a UserTalk Script Is Like.) Separates items in the parentheses form of loop().
Comment starter. Causes itself and everything following on the same line to be considered a comment.
Line continuation marker; at the end of a line, causes the next line to be considered part of the same command. In string and char literals, the "escape" marker, making it possible to type special characters.
Dictates order of evaluation; used after the name of a script object to make a call to it. Parameters go inside. Required in a handler definition (on line). Parameter variables go inside. Required after fileloop. Used in the parentheses form of loop().
Delimits a bundle when a script is in a text context (as opposed to a script object); a single line of a script in a script object counts as a text context. (See Chapter 4.) Delimits a list/record literal.
Delimits a string literal.
Delimits a string literal. On the interplay between straight and curly double-quotes, see the discussion of string literals in Chapter 10, Datatypes.
In an object reference, used to force pre-evaluation of the enclosed expression; the result of the evaluation becomes a single element of the name. Denotes an index in array notation. Denotes an index in an object specifier in object-model syntax.
TOP | UP: Reference | NEXT: Verbs |