Shorthand numeric updates

From Color 64 BBS Wiki

Programming Features - Shorthand Numeric Updates

Color 64 allows a numeric variable or numeric array element to be updated without repeating the variable name on the right side of the assignment.

For example: A+12 is equivalent to: A=A+12

Subtraction is also supported: A-12 is equivalent to: A=A-12

When no expression follows the operator, Color 64 assumes a value of one: A+ is equivalent to: A=A+1

A- is equivalent to: A=A-1

The value following the operator may be any valid numeric BASIC expression. For example:

  • A+X*2
  • A-(B+C)
  • HM+
  • N%(I)-1

Both floating-point and integer variables are supported, including array elements. String variables are not supported by this shorthand syntax.

Only the addition (+) and subtraction (-) operators should be used. Other arithmetic or logical operators are not supported in this form.

Note: Shorthand updates to integer variables use direct 16-bit arithmetic. If the result exceeds the integer range of -32768 through 32767, the value may wrap around rather than generate an overflow error.

Next Section: ML Command Set