Hi Dan,
even the code you posted does not compile - simply because INT is not datatype in PowerBASIC. INT in powerBasic, as well as thinBasic, is function to "convert a numeric expression to an integral value".
When you need integer variable in PowerBASIC, you have this possible variants:
- INTEGER - for 16bit
- LONG - for 32bit
- QUAD - for 64bit
The available datatypes are documented in PB/Help file under "Data Types" root chapter. Integral datatypes (both signed and unsigned) are documented in Data types/Integral data types.
So the following compiles just fine...:
#COMPILE EXE
#DIM ALL
GLOBAL i AS INTEGER
SUB s()
GLOBAL j AS INTEGER
END SUB
FUNCTION PBMAIN () AS LONG
GLOBAL k AS INTEGER
END FUNCTION
Might be of interest that when using DIM, the compiler picks GLOBAL/LOCAL scope based on the declaration position:
#COMPILE EXE
#DIM ALL
DIM i AS INTEGER ' -- Will become GLOBAL variable, as DIM is used in GLOBAL space
SUB s()
DIM j AS INTEGER ' -- Will become LOCAL variable, as DIM is used inside SUB/FUNCTION/METHOD space
END SUB
FUNCTION PBMAIN () AS LONG
DIM k AS INTEGER ' -- Will become LOCAL variable, as DIM is used inside SUB/FUNCTION/METHOD space
GLOBAL k2 AS INTEGER ' -- Using GLOBAL forces the variable to be GLOBALy visible
END FUNCTION
Petr
Bookmarks