Function

From C64-Wiki
Jump to: navigation, search

A function is similair in mathematics also in IT a mathematical formula, which allocate each X value a Y value.

X = -1 : PRINT ABS(X)
Screen / output: 1

Also subroutines can be a function, if this routine returns a value (of course in variables). In the Commodore BASIC aren't needed returns with variables, because all variables are used in the whole BASIC program.

10 A = 10: B = 5
20 GOSUB 100
30 PRINT A, B
99 END
100 REM *** Change function ***
101 C = A : A = B : B = C : C = 0: RETURN
Screen / output: 5    10

The BASIC V2 of the C64 has this basically mathemathical functions like ABS, ATN, COS, EXP, INT, LOG, SGN, SIN, SQR and TAN.

A few special functions, which returns also a numeric value:

Also a few functions for string handling or converting:

Cursor functions:

  • For positioning a cursor: SPC( and TAB(
  • For peeking out the actually cursor position: POS