MY-BASIC is a lightweight BASIC interpreter written by Wang Renxin. The C++ code is embedded in HPx and extended with the PHREEQC & HPx script functions. In contrast to the PHREEQC-BASIC interpreter, it allows for modern BASIC syntax with following main features:

    • no line numbering
    • including structured IF/THEN/ELSE, subroutine (DEF/ENDDEF), FOR/TO/STEP/NEXT, FOR/IN/NEXT, WHILE/WEND, and DO/INTIL routines
    • collections (LIST,DICT)
    • import of multiple source files (IMPORT)
    • prototype based programming as a style for object-oriented programming (CLASS/ENDCLASS)
    • lambda abstraction


In the remaining of this page, a few important elements of the MY-BASIC language are summarized. More information can be found in the external help file.


A short explanation of the myBasic language is given in this help file:

Variables


Some names are reserved for the MY-BASIC language


Operators


+, -, *, /, ^, =, <, >, <=, >=, <>


MOD



AND



OR



NOT



IS





Keywords


Structured routine


DEF

Begin of a structured routine


ENDDEF

End of a structured routine


CALL

Calls a structured routine

Required when structure routine is called before its definition 

RETURN

Return value of the routine

if not defined, the routine returns the value of the last expression



Example



Instructional routine


GOSUB

go to a routine identified 


RETURN

exit the routine 




Important - Structured and instructional routines can not mixed in one script.


Control structures



Conditional structures

IF .. THEN .. ELSEIF .. ELSE .. ENDIF

Loop structures

FOR .. TO .. STEP ... NEXT


loop for certain steps


STEP

if a step increase is different from 1


FOR .. IN .. NEXT


to iterate in a for structure in a list, dictionary, ...


WHILE .. WEND


loop uncertain amount of times

loop while condition is true

condition is checked before the loop


DO .. UNTIL


loop uncertain amount of times

loop until condition is false

condition is checked at the end of the loop


EXIT

to interrupt current loop and continues the script after loop



Class



Lambda



Standard library

Numerical functions


ABS

absolute value


ACOS



ASIN



ATAN



CEIL



COS



EXP



FIX



FLOOR



LOG



RND



ROUND



SGN



SIN



SRND



SQR



TAN




String functions


ASC



CHR



LEFT



MID



RIGHT



STR




Common

LEN



VAL




Input & Output

Not active in HPx

INPUT



PRINT