The ADD command can be used to add the result of an expression to a whole number variabk. immediately. It is the equivalent to variable=variable+ expression but performs the addition nearly twice as fast.
There is a more complex version of ADD, which is ideal for handling certain loops much more quickly than the equivalent separate instructions. When Base number and Top number parameters are included, ADD is the equivalent to the following lines:
X> V=V+A If V<BASE Then V=TOP If V>TOP Then V=BASE
Here is an example:
E> Dim A(10) For X=0 To 10:A(X)=X:Next X V=0 Repeat Add V,1,1 To 10 Print A(V) Until V=11 : Rem This loop is infinite as V is always <11
Relative values
It is obvious that every expression has a value, but expressions are not restricted to
whole numbers (integers), or any sort of numbers. Expressions can be created from real numbers
or strings of characters. If you need to compare two expressions, the following functions are
provided to examine them and establish their relative values.
MAX
function: return the maximum of two values
value=Max(a,b)
value#=Max(a#,b#)
value$=Max(a$,b$)
MAX compares two expressions and returns the largest. Different types of expressions cannot be compared in one instruction, so they must not be mixed.
Here are some examples:
D> Print Max(99,1) Print Max("AMOS Professional","AMOS")
MIN
function: return the minimum of two values
value=Min(a,b)
value#=Min(a#,b#)
value$=Min(a$,b$)