PB Types & Variables

Data Types

TypeSuffixSizeRange
BYTE?8-bit0 to 255
WORD?16-bit0 to 65535
DWORD?32-bit0 to 4,294,967,295
INTEGER%16-bit-32,768 to 32,767
LONG&32-bit-2,147,483,648 to 2,147,483,647
QUAD&&64-bitVery large integers
SINGLE!32-bitIEEE 754 float (partial support)
DOUBLE#64-bitIEEE 754 double (partial support)
EXT##80-bitx87 extended (partial support)
STRING$VariableASCIIZ fixed-length buffer
WSTRING$$VariableUTF-16 (partial support)
CURRENCY@64-bitFixed-point (4 decimals)
Note: STRING variables are implemented as fixed-length local ASCIIZ buffers. Full dynamic string runtime (heap allocation, automatic cleanup, capacity growth) is not yet implemented.

Variable Declarations

LOCAL

Syntax: LOCAL name[(bounds)] AS type

Declares a procedure-local variable. Must appear at the top of a FUNCTION or SUB before executable statements.

LOCAL x AS LONG
LOCAL name$ AS STRING
LOCAL price AS SINGLE

DIM

Syntax: DIM name[(bounds)] AS type

Declares a variable (equivalent to LOCAL in the current implementation).

DIM count AS LONG

STATIC

Syntax: STATIC name AS type

Declares a variable that retains its value between calls to the procedure.

STATIC callCount AS LONG

GLOBAL

Syntax: GLOBAL name AS type

Declares a module-level global variable. Partial support only.

GLOBAL g_counter AS LONG

Arrays

Fixed Arrays

Arrays with a compile-time constant size:

LOCAL a(10) AS LONG          ' 0 to 10 (11 elements)
LOCAL b(1 TO 5) AS LONG      ' 1 to 5 (5 elements)
LOCAL names$(20) AS STRING   ' String array (limited)

Dynamic Arrays (REDIM)

Stack-backed dynamic arrays; bounds established at runtime:

LOCAL arr() AS LONG
REDIM arr(1 TO n) AS LONG    ' Allocate n elements
arr(3) = 42                  ' Element assignment
x = arr(3)                   ' Element read
Note: REDIM PRESERVE (preserving existing data on resize) is not yet supported. Arrays are stack-backed, not heap-allocated.

Array Functions

FunctionDescriptionExample
LBOUND(a)Lower bound of arrayPRINT LBOUND(arr)
UBOUND(a)Upper bound of arrayPRINT UBOUND(arr)

String Functions

FunctionDescription
LEN(s$)Returns the length of a string
STRPTR(s$)Returns a pointer to the string data (for WinAPI calls)
VARPTR(v)Returns a pointer to a variable
LEFT$(s$, n)Returns the leftmost n characters
RIGHT$(s$, n)Returns the rightmost n characters
MID$(s$, start, n)Returns n characters from position start
TRIM$(s$)Removes leading and trailing spaces
LTRIM$(s$)Removes leading spaces
RTRIM$(s$)Removes trailing spaces
UCASE$(s$)Converts to uppercase
LCASE$(s$)Converts to lowercase

String Operations

s$ = "Hello"
t$ = s$ + ", World"          ' Concatenation with +
IF s$ = t$ THEN ...          ' Equality comparison
IF s$ <> t$ THEN ...         ' Inequality comparison
IF s$ < t$ THEN ...          ' Relational comparison

TYPE (User-Defined Type)

Partial support for structured types with numeric, STRING, and nested TYPE fields:

TYPE Point
    x AS DOUBLE
    y AS DOUBLE
END TYPE

LOCAL p AS Point
p.x = 3.0
p.y = 4.0

Numeric Literals

BasePrefixExample
Decimal(none)42, -100
Hexadecimal&H&HFF, &H0A2B
Octal&O&O77, &O377
Binary&B&B1010, &B11110000

Expressions & Operators

CategoryOperators
Arithmetic+ - * / \ (integer) MOD ^
Comparison= <> < > <= >=
String+ (concatenation), = <> < >