PowerBASIC Users Meeting Point
What is different - Printable Version

+- PowerBASIC Users Meeting Point (http://pump.richheimer.de)
+-- Forum: Special Interest Groups (http://pump.richheimer.de/forumdisplay.php?fid=23)
+--- Forum: JKB (32/64 bit Compiler) (http://pump.richheimer.de/forumdisplay.php?fid=24)
+--- Thread: What is different (/showthread.php?tid=123)



What is different - Juergen Kuehlwein - 12.04.2026

What´s different

The syntax is (with some minor restrictions) compatible to PowerBASIC. These restrictions are:


- Variables must not be declared with "DIM" anymore! 
    LOCAL, GLOBAL, STATIC, INSTANCE or COMMON is required (= #DIM ALL in PB)!. Dim is exclusively used for dimensioning arrays. THREADED is not supported ATM.

- You may still declare multiple variables of the same data type in one single line. "LOCAL a, b, c AS LONG" is accepted. "LOCAL a$, b AS DWORD, c AS LONG" throws an error, because a$, b and c represent different data types.


- You may assign an intial value, e.g. "LOCAL x AS LONG = -1"


- With variables you cannot have type specifiers anymore except for "$" (dynamic ANSI string) or "$$" (dynamic wide string)


- There are new data types: QWORD (unsigned 64 bit integer), SBYTE (signed 8 bit integer), XWORD (DWORD in 32 bit and QWORD in 64), XLONG (LONG in 32 bit and QUAD in 64)


- Assembler code:   
    ! cmp byte [esi], 0  -> byte ptr (the key word "ptr" is mandatory, assembler error otherwise)
    ! ret must become,  ! retn, (ret ends a stackframe)

    !.if (eax == 0)
    ! ... "
    !.endif                     (MASM Hi-level syntax is possible)

    XAX = EAX in 32 bit and RAX in 64 bit


- Reserved words: there is a list of words, which are forbidden as variable or procedure names, eg. pos, count, enter, comment et. al


- String expressions: no logical string expressions, but automatic build$
    e.g.        if a$ < b$ and c$ < d$ then
                 ...
           
    must be    if a$ < b$ then
                      if c$ < d$ then
                      ...
             
    but a$ + b$ + c$, is always compiled as BUILD$(a$, b$, c$), BUILD$ is valid syntax, but it is not necessary anymore             



- Conditional compiling: code inside conditional compiling blocks (even if condition is not met) must be compilable
    you cannot code anymore:
    #IF 0
    <your comments here> -> you must pepend an apostrophe to make it a comment
    #ENDIF


#TRACE, #PROFILE and #CALLSTACK make use of the OutputDebugString Viewer, this is still experimental


- Syntax:
PARSE        (no special treatment for default separator "," and quotes)

ISTRUE      (parenthesis are required, it´s a function not an operator)
ISFALSE      (parenthesis are required, it´s a function not an operator)

FORMAT$      (only one formatting mask allowed)
JOIN$        (without BINARY option and special quote handling)
PARSE$      (without BINARY option and special quote handling)

PRINT        (requires sparator (, ; spc() tab()) between expressions)



What´s new:

#SEH - in case of a GPF, the offending line is shown in the IDE

TIMING [END]  -  return elapsed time in µs, syntax: TIMING [END] qword/quadvar
ISVALID(<ptr>) -  returns -1, if pointer points to valid memory, 0 otherwise

SIN            -  y = SIN([deg/rad], x) default is deg, applies to all trigonometric functions

ZIP:                                                                                  'zip into ziparchive
' ZIP string s$, filename (in ziparchive), ziparchive [, password] [, call callback]
' ZIP filename(s), ziparchive [, password] [, call callback]
' ZIP memory ptr, len, filename (in ziparchive), ziparchive [, password] [, call callback]
ZIP$:                                                                                  'zip into string
' z$ = ZIP$(string s$, filename (in archive) [, password] [size = x] [, call callback])
' z$ = ZIP$(filename(s) [, password] [size = x] [, call callback])
' z$ = ZIP$(memory ptr, len, filename (in archive) [, password] [size = x] [, call callback])
UNZIP:                                                                                'unzip ziparchive
' UNZIP filename(s) (in string), string s$ [, password] [to folder] [, call callback]
' UNZIP filename(s) (in ziparchive), ziparchive [, password] [to folder] [, call callback]
' UNZIP filename(s) (in memory), memory ptr, len [, password] [to folder] [, call callback]
UNZIP$                                                                                'unzip into string
' s$($) = UNZIP$(filename (in string), string z$|ziparchive] [, password])
' s$($) = UNZIP$(filename (in ziparchive), ziparchive] [, password])
' s$($) = UNZIP$(filename (in memory), memory ptr, len|ziparchive] [, password])
ZIPINFO:                                                                              'return # of files in zip + array of zipinfo
' x = ZIPINFO(array, string z$|ziparchive [, password])           
' x = ZIPINFO(array, memory ptr, len|ziparchive [, password])
ZIPCALC:                                                                              'return # of bytes for zipped data
' x = ZIPCALC(string s$|filename(s))
' x = ZIPCALC memory ptr, len|filename(s)
UNZIPCALC:                                                                            'return # of bytes for unzipped data
' x = UNZIPCALC( filename(s), string z$|ziparchive [, password])
' x = UNZIPCALC( filename(s), memory pointer, len|ziparchive [, password])



Run 32 bit code:
As a first step try to run 32 bit code. Please adapt your code according to the above restrictions. If there are many places to adapt, the Replace Dialog (Ctrl + R) is your friend. The first line must be "#COMPILER JKB [32]", "F9" compiles and executes. The IDE will complain about errors.


Run 64 bit code:
64 bit code definitely needs adaptions: all pointers and handles (which are pointers in fact) must become 64 bit data types (DWORD -> XWORD and LONG -> XLONG). The first line must be "#COMPILER JKB 64".



There is a (still experimental) code converter (Credits to Norbert Spoerl for supplying ideas and major parts of code) for adapting existing code to the new requirements. You may use the menu (last item in "File" menu: "Prepare Source for JKB" ) or the top toolbar (a new button, next to the "command prompt" button on the right side). This feature is applied to current file in the IDE. A copy (<name>.original) is made before. Yet you may still have to adapt some things manually.



Please don´t post in this thread, feel free to ask questions in "Discussions" thread