in BASIC ROM:
|List of all BASIC keywords|
Typ: Integer Function General Programming-Syntax: POS(<dummy argument>)
The function POS determined the actual position of the cursor between 0 (first, leftmost column) and 79 (last, rightmost column in the second line) of the logical line on screen. The dummy argument is mandatory, but it does not have any effect on the result. Usually POS(0) will be used. The fastest possible execution time provides the form POS(π).
If the dummy argument is missing the BASIC error ?SYNTAX ERROR will occur.
Some strangeness of the BASIC interpreter is revealed if a program (in direct mode too) calls the function with a distinct kind of string-type expression (see Examples). This behavior can be provoked with a constant string as an argument for POS() used multiple times. On the third call an internal structure (string descriptor stack, keeping temporarily created strings) gets filled, because of missing housekeeping for the argument strings. This leads to the error ?FORMULA TOO COMPLEX ERROR. In contrast, the FRE() function also uses a dummy argument, but does a proper cleanup not leading to this effect.
At first, place the writing position to column 30 (the 31st), then query the position and print the value:
Since POS() demands a single argument, which is not used, it could be selected in that way the interpreter takes as less time as possible to evaluate it - just in case the function is part of an iteration:
The expression for the argument of POS() evaluates fastest with with the special constant π (Pi), followed by a . (a degenerated number which translates to a float in the fastest possible way). Even a variable (declared very early) cannot reach the previous mentioned in speed. Compared to them a "0" is the slowest variant.
Anomaly of the interpreter with a constant string as dummy argument:
terminates with the error ?FORMULA TOO COMPLEX ERROR. The number of POS() calls needed may vary for different CBM BASIC versions, which might use other limits on internal structures.