Skip to content

vallib

Val turns a string into a number, Int, Frac, Sgn and Abs work on numbers of any type, and Rnd gives random numbers. The functions whose names begin with Q work on quick values, the fixed point numbers of Blitz Basic with 16 bits before and 16 bits after the point, and are fast because they need no floating point. True and False are the values -1 and 0 that Blitz Basic uses for true and false. NTSC, DispHeight and VPos tell a program about the display it runs on.

Floating point values are Motorola fast floating point numbers, computed with the system’s mathffp.library.

Library number 120.

Commands

Abs

The absolute value, as a float. Takes a value of any numeric type.

Function, result .f. Help text: (Expression)
Arguments: any

DispHeight

The height of the display, 200 lines for NTSC or 256 for PAL.

Function, result .w. No help text.
No arguments.

False

The value 0, Blitz Basic’s false.

Function, result .w. No help text.
No arguments.

Frac

The fractional part of the value, as a float, with the sign of the value. Takes a value of any numeric type; the fraction of a Quick is exact.

Function, result .f. Help text: (Expression)
Arguments: any

Int

The integer part of the value, as a long; the fraction is cut off towards 0. Takes a value of any numeric type.

Function, result .l. Help text: (Expression)
Arguments: any

NTSC

True (-1) if the display is NTSC, false (0) if it is PAL.

Function, result .w. No help text.
No arguments.

QAbs

The absolute value of the quick value.

Function, result .q. Help text: (Quick)
Arguments: .q

QAngle

The direction of the line from the destination point to the source point, as a quick value from 0 up to but not including 1, the fraction of a full turn.

Function, result .q. Help text: (Src X,Src Y,Dest X,Dest Y)
Arguments: .w, .w, .w, .w

QFrac

The fractional part of the absolute value of the quick value.

Function, result .q. Help text: (Quick)
Arguments: .q

QLimit

The quick value limited to the range from Low to High.

Function, result .q. Help text: (Quick,Low,High)
Arguments: .q, .q, .q

QWrap

The quick value wrapped into the range from Low up to but not including High, by adding or subtracting the size of the range once.

Function, result .q. Help text: (Quick,Low,High)
Arguments: .q, .q, .q

Rnd

A random number, from 0 up to but not including 1 without an argument, or up to but not including Range with one.

Function, result .q. Help text: [(Range)]
2 forms:

  • no arguments
  • .w

Range is taken as an unsigned word, so Rnd(-1) is the same as Rnd(65535). The numbers come from the hardware’s beam position, a joystick register and a CIA timer, not from a sequence that can be repeated.

Sgn

The sign of the value, -1, 0 or 1. Takes a value of any numeric type.

Function, result .q. Help text: (Expression)
Arguments: any

True

The value -1, Blitz Basic’s true.

Function, result .w. No help text.
No arguments.

Val

The numeric value of the string, as a float. Leading spaces are skipped; a $ in front reads a hexadecimal number, a % a binary one, and a - a negative one. The empty string gives 0.

Function, result .f. Help text: (String$)
Arguments: $

Of the decimal places, the first 9 count; the others are skipped.

Fixed in the port: for hexadecimal, binary and negative numbers the original read one character behind the string, and took a digit there as part of the number (#302).

VPos

The line the video beam is on at this moment.

Function, result .w. No help text.
No arguments.