This page uses CSS, and renders properly in the latest versions of
Microsoft Internet Explorer and
Mozilla.
This is
Frontier: The Definitive Guide by
Matt Neuburg, unabridged and unaltered from the January 1998 printing.
It deals with the
freeware Frontier 4.2.3; for commercial Frontier 8, look
here, and for the inexpensive Radio UserLand, look
here. See
my Web site for information.
Those wishing an offline or printed copy may purchase the book, which is still
in print.
Copyright 1998
O'Reilly & Associates, Inc. ALL RIGHTS RESERVED. Reprinted with permission.
44
Operators
UserTalk operators are, for the most part, C-like. On datatypes and implicit coercion, see Chapter 10, Datatypes. On list, record, and string operations, see also Chapter 11, Arrays. On arithmetic operations, see also Chapter 15, Math. String comparisons are case-sensitive; see also Chapter 45, Punctuation.
=
Performs assignment. The value and datatype of the right side are assigned to the object named on the left side, which may be created if it does not already exist (in accordance with the rules discussed Chapter 6, Referring to Database Entries and Chapter 7, The Scope of Variables and Handlers).
Frontier will balk at using assignment to replace an non-scalar type with a scalar, but apart from this, Frontier will happily replace one datatype with another. Use of the assignment operator does not cause implicit type coercion.
+
This operator is overloaded, representing (1) numerical addition, (2) string concatenation, and (3) list/record concatenation. Implicit coercion takes place if the operands are of different types. If neither operand is of any of these types, there may be implicit coercion to a string or a number; if to a number, the result may be coerced back (see Chapter 10).
-
This operator is overloaded, representing (1) numerical subtraction, (2) substring removal, and (3) sub-list/record removal. Implicit coercion takes place if the operands are of different types. If neither operand is of any of these types, there may be implicit coercion to a string or a number; if to a number, the result may be coerced back (see Chapter 10).
*
Multiplies two numbers. Implicit coercion takes place if the operands are of different types. If neither operand is a number, there may be implicit coercion to a number, and the result may be coerced back (see Chapter 10).
/
Divides the left operand by the right operand. If neither operand is a number, there may be implicit coercion to a number, and the result may be coerced back (see Chapter 10).
%
Modulus or remainder operator; returns the remainder when the first operand is divided by the second. If both operands are not integers (or integer equivalents), a runtime error is generated. Synonym: mod().
++
Increment. As in C, the operator is either prefixed or suffixed to the name of a numeric object, and the object's value has 1
added to it either before or after evaluating the surrounding expression, respectively. It is not an error to apply this to a non-number, but the results are not meaningful (no implicit coercion takes place) and it can be a bad idea.
--
Decrement. As in C, the operator is either prefixed or suffixed to the name of a numeric object, and the object's value has 1
subtracted from it either before or after evaluating the surrounding expression, respectively. It is not an error to apply this to a non-number, but the results are not meaningful (no implicit coercion takes place) and it can be a bad idea.
@
Address of. When used before the name of an object, returns a pointer to that object. See Chapter 8, Addresses.
^
Dereference. Using the name of an address object followed by ^
equates to using the name of the object pointed at by the address object. Using the name of a string object followed by ^
equates to using the string as a name. See Chapter 8.
Operators Used in Boolean Expressions
==
Logical equality. Synonym: equals. Used in boolean expressions to test for equality. It is a common beginner's mistake to use =
instead:
if a = 7 « wrong
Fortunately this generates a syntax error and won't compile. Implicit coercion takes place if the operands are of different types.
!=
Logical inequality. Synonyms: ≠ (typed with Option-= on the Mac), not-equals. Note that <>, used by many languages to express inequality, is not valid in UserTalk. Used in boolean expressions to test for inequality. Implicit coercion takes place if the operands are of different types.
<
Logical less-than. Synonym: lessthan. Used in boolean expressions to test whether the first operand is less than the second. Implicit coercion takes place if the operands are of different types.
<=
Logical less-than-or-equals. Synonym: ≤ (typed with Option-period on the Mac). Used in boolean expressions to test whether the first operand is less than or equal to the second. Implicit coercion takes place if the operands are of different types.
>
Logical greater-than. Synonym: greaterthan. Used in boolean expressions to test whether the first operand is greater than the second. Implicit coercion takes place if the operands are of different types.
>=
Logical greater-than-or-equals. Synonym: ≥ (typed with Option-comma on the Mac). Used in boolean expressions to test whether the first operand is greater than or equal to the second. Implicit coercion takes place if the operands are of different types.
!
Logical not. Synonym: not. Used in boolean expressions to reverse the truth value of the boolean that follows it. Implicit coercion takes place if the operand is not a boolean.
&&
Logical and. Synonym: and. Operates on two booleans, yielding true
only if they are both true. If the first operand is false, the second will never be evaluated ("short-circuiting"). Implicit coercion takes place if an operand is not a boolean.
||
Logical or. Synonym: or. Operates on two booleans, yielding true
if either is true. If the first operand is true, the second will never be evaluated ("short-circuiting"). Implicit coercion takes place if an operand is not a boolean.
beginsWith
Logical begins-with. If the left operand is a list/record, the second operand is coerced to the same and true
is returned if the elements of the second operand appear, together, in order at the start of the first. Otherwise, both operands are coerced to strings and true
is returned if the first string begins with the second as a substring.
contains
Logical contains. If the left operand is a list/record, the second operand is coerced to the same and true
is returned if the elements of the second list appear together, in order, in the first. Otherwise, both operands are coerced to strings and true
is returned if the first string contains the second as a substring.
endsWith
Logical ends-with. If the left operand is a list/record, the second operand is coerced to the same and true
is returned if the elements of the second list appear together, in order, at the end of the first. Otherwise, both operands are coerced to strings and true
is returned if the first string ends with the second as a substring.
This is
Frontier: The Definitive Guide by
Matt Neuburg, unabridged and unaltered from the January 1998 printing.
It deals with the
freeware Frontier 4.2.3; for commercial Frontier 8, look
here, and for the inexpensive Radio UserLand, look
here. See
my Web site for information.
Those wishing an offline or printed copy may purchase the book, which is still
in print.
Copyright 1998
O'Reilly & Associates, Inc. ALL RIGHTS RESERVED. Reprinted with permission.