Oxygen Basic Compiler - documentation.help · Oxygen Basic (o2H) is a Just-In-Time compiler...

214
Oxygen Basic Compiler Copyright © Charles E V Pegge, 2010-2018

Transcript of Oxygen Basic Compiler - documentation.help · Oxygen Basic (o2H) is a Just-In-Time compiler...

Page 1: Oxygen Basic Compiler - documentation.help · Oxygen Basic (o2H) is a Just-In-Time compiler assembler, deployed in a single DLL that takes source code strings and returns executable

OxygenBasicCompiler

Copyright©CharlesEVPegge,2010-2018

Page 2: Oxygen Basic Compiler - documentation.help · Oxygen Basic (o2H) is a Just-In-Time compiler assembler, deployed in a single DLL that takes source code strings and returns executable

IntroductionOxygenBasic(o2H)isaJust-In-Timecompilerassembler,deployedinasingleDLLthattakessourcecodestringsandreturnsexecutablebinary.ItisanextensionoftheO2assembler.Thisimplementationcanbeembeddedinanyapplicationtoprovidehighperformanceprogrammability.Thecompilercanalsogenerateconventionalexecutablesanddynamiclinklibraries(DLL).

OxygensupportsObjectOrientedProgrammingwithmultipleinheritanceandalsosingleinheritancemodes,moresuitedtoCOM.InadditiontothisO2HsupportsUser-definedoperatorsandoperatorsetsforusewithcomplexnumbers,matrices,vectors,setsandotherspecialisedforms.Itcanalsocompile&executestringsofsourcecodeatruntimewithitsbuiltincompile()function,openingnewpossibilitiesforfunctionalprogramming.

Thebuiltinfunctionsetissmall.butcontainsthenecessarytoolstobuildclass/functionlibrariestoanyscale.

InadditiontounderstandingBasicintheQBasicgenre,OxygencanreadsufficientCsyntaxtodealwithmostCheadersdirectly,eliminatingtheneedtotranslatethemintoBasic.

Copyright©CharlesPegge,2010

Page 3: Oxygen Basic Compiler - documentation.help · Oxygen Basic (o2H) is a Just-In-Time compiler assembler, deployed in a single DLL that takes source code strings and returns executable

typesvoid,sbyte,ubyte,byte,string,string2,wstring,bstring,gstr_,bstr,bstring2,char,wchar,cstr_,asciiz,zstring,zstring2,asciiz2,short,wide,long,int,integer,float,single,double,extended,quad,word,dword,ulong,uint,qword,any,sys,boolean,bool,

USE: tospecifythetypesofvariablesandcreatethemEXAMPLE:

intx

dimasintx

dimxasint

varintx

Page 4: Oxygen Basic Compiler - documentation.help · Oxygen Basic (o2H) is a Just-In-Time compiler assembler, deployed in a single DLL that takes source code strings and returns executable

dimsyntaxdim,

REMARKS: Cstyleinstantiationsisasimpleralternativetousing'Dim'.

RELATED: globallocalstatic

'--------------

'DIMVARIATIONS

'==============

'----------------

'POSTDEFINETYPE

'================

dimi,j,kaslong

'---------------

'PREDEFINETYPE

'===============

dimaslongi,j,k

'-----------

'MIXEDTYPES

'===========

dimaslongi,j,k,asstrings,t

'----------

'MULTILINE

'==========

dimaslongi,j,k,

asstrings,t

dimaslong,

i,

j,

k

'--------------

Page 5: Oxygen Basic Compiler - documentation.help · Oxygen Basic (o2H) is a Just-In-Time compiler assembler, deployed in a single DLL that takes source code strings and returns executable

'INITIALVALUES

'==============

dimaslong,

i=1,

j=2,

k=42

'-------------------------

'SPREADLINESANDCOMMENTS

'=========================

dimaslong,

i=1,'thesecanbespreadovermanylines

'--------

j=2,'withinterveningcomments

'--------

k=42'

'--------------------

'MULTIPLEASSIGNMENTS

'====================

dimaslonga(10)=>(2,4,6,8,10,12,42,99)

print"Answer:"stra(7)

'-----------------

'SYNTAXVARIATIONS

'=================

dimlonga(10)=>(2,4,6,8,10,12,42,99)

dimlonga[10]=>(2,4,6,8,10,12,42,99)

longa[10]=>(2,4,6,8,10,12,42,99)

longa[10]<=(2,4,6,8,10,12,42,99)

longa[10]={2,4,6,8,10,12,42,99}

longa[]={2,4,6,8,10,12,42,99}

longa={2,4,6,8,10,12,42,99}

longa=

{

2,4,6,8,10,12,42,99

}

Page 6: Oxygen Basic Compiler - documentation.help · Oxygen Basic (o2H) is a Just-In-Time compiler assembler, deployed in a single DLL that takes source code strings and returns executable

'------------------

'POINTEREDVARIABLE

'==================

dimstrings="ABCDEFGHIJ"

dimbytebatstrptrs

dimbytebyrefb:@b=strptrs

bytebatstrptrs

byte*b=strptrs

'printb[7]'71G

'--------------------

'USINGDYNAMICMEMORY

'====================

dimfloatfatgetmemory1024*4:f={1.5,2.5,3.5}

'printf[2]

freememory@f'releaseallocatedmemory

'---------------------------

'DIMS:GLOBAL,STATIC,LOCAL

'===========================

globalintg=1'visibletorestofprogramfollowingthisstatement

functionf(pasint)asint

staticints=0'permanentstorage

localintl=100'temporarystorage

s+=10

returnp+l+s+g

endfunction

printf(1000)'1111

printf(1000)'1121

'--------------

'LIMITINGSCOPE

'==============

dimlonga=16

Page 7: Oxygen Basic Compiler - documentation.help · Oxygen Basic (o2H) is a Just-In-Time compiler assembler, deployed in a single DLL that takes source code strings and returns executable

scope

dimlonga=1

'printa'1

...

endscope

'printa'16

Page 8: Oxygen Basic Compiler - documentation.help · Oxygen Basic (o2H) is a Just-In-Time compiler assembler, deployed in a single DLL that takes source code strings and returns executable

inhstructurestype,

USE: specifycompundstructureforavariableRELATED: structtypedef

'--------------

'COMPOUNDTYPES

'==============

typecolor32

rasbyte

gasbyte

basbyte

aasbyte

=

rgbaaslong'UNION

endtype

'-------------

'DERIVEDTYPE:

'=============

typecolortext

txtasstring

cascolor32

endtype

dimtascolortext

t.txt=`Colorcode`

t.c.r=8

t.c.b=16

t.c.g=32

t.c.a=64

printt.txthext.c.rgba

Page 9: Oxygen Basic Compiler - documentation.help · Oxygen Basic (o2H) is a Just-In-Time compiler assembler, deployed in a single DLL that takes source code strings and returns executable

'print"STRUCTURE:

'"structureofcolor32

'-----------------

'SYNTAXVARIATIONS

'=================

typecolor32

byter

byteg

byteb

bytea

=

longrgba'UNION

endtype

typecolor32

byter,g,b,a

=

longrgba'UNION

endtype

typecolor32byter,g,b,a=longrgba

typecolortextstringtxt,color32c

structcolor32{

byter,g,b,a

=

longrgba

}

typedefstruct_color32{

byter,g,b,a

=

longrgba

}color32,*pcolor32

typedefstruct_color32{

union{

struct{

byter,g,b,a

}

longrgba

Page 10: Oxygen Basic Compiler - documentation.help · Oxygen Basic (o2H) is a Just-In-Time compiler assembler, deployed in a single DLL that takes source code strings and returns executable

}

}color32,*pcolor32

'#recordofcolor32

'#recordof_color32

'#recordofcolortext

Page 11: Oxygen Basic Compiler - documentation.help · Oxygen Basic (o2H) is a Just-In-Time compiler assembler, deployed in a single DLL that takes source code strings and returns executable

includesonce,

ACTION: ensuresthatafileisincludedinthesourcecodeoneonly.EXAMPLE:

#includeonce"../../MinWin.inc"

RELATED: include#includeincludepath

Page 12: Oxygen Basic Compiler - documentation.help · Oxygen Basic (o2H) is a Just-In-Time compiler assembler, deployed in a single DLL that takes source code strings and returns executable

equates$,%,

REMARKS: $and%areequivalent

RELATED: def#defmacro#define

'$filename"t.exe"

'usesrtl64

'---------------

'EQUATES:$or%

'===============

'strictlyspeakingthesearesingle-linemacros

%a=1

%b=2

%c3

%c3

%c=3

$d4

$d"four"

%d"four"

%=eb*c'precalcuateevalue'6

'#recordofe

%f8

%%f7'defaultvalue7(unlesspreviouslydefined)

%sp""

%cm","

'$%prefixesandsuffixesareignored

print""acmbcmccmdcmecmf'1,2,3,four,6,8

'print%acm%bcm%ccm%dcm%ecmf

'INCLUDINGARGUMENTS

Page 13: Oxygen Basic Compiler - documentation.help · Oxygen Basic (o2H) is a Just-In-Time compiler assembler, deployed in a single DLL that takes source code strings and returns executable

'argumentsarerepresentedby%1..%9

%display"valueof%1:"%1

printdisplayd

Page 14: Oxygen Basic Compiler - documentation.help · Oxygen Basic (o2H) is a Just-In-Time compiler assembler, deployed in a single DLL that takes source code strings and returns executable

arraysarrays,

REMARKS: Onlysingledimensionedarraysaredirectlysupported

RELATED: dim

'%filename"t.exe"

'usesrtl64

'-------------

'STATICARRAYS

'=============

dimaslonga(10)={2,4,6,8,10,12}

a(10)=a(1)+a(4)

printa(10)

'--------------

'DYNAMICARRAYS

'==============

dimaslongaatgetmemory(10*sizeof(long)):a={2,4,6,8,10,12}

...

freememory@a

dimaslonga(10)={2,4,6,8,10,12}

'--------

'OVERLAYS

'========

dimasstrings="ABCDEFGHIJ"

dimasbytebatstrptr(s)

printstr(b[3])":"chr(b[3])

'-----------------------

'MULTIDIMENSIONALARRAYS

'=======================

macroa(x,y)av(y*1024+x)

dimintav[1024*1024]

Page 15: Oxygen Basic Compiler - documentation.help · Oxygen Basic (o2H) is a Just-In-Time compiler assembler, deployed in a single DLL that takes source code strings and returns executable

a(100,200)=42

printa(100,200);42

'----------

'INDEXBASE

'==========

'

diminta[100]={10,20,30,40}

indexbase1'default:firstelementisindexedas1

'printa[2]'20

indexbase0

printa[2]'30

'-------------

'PSEUDOARRAYS

'=============

dimav[100]

functiona(inti,v)'setter

i*=2

av[i]=v

endfunction

functiona(inti)asint'getter

i*=2

returnav[i]

endfunction

a(7)=42'thisisinterpretedasa(7,42)

'printa(7)

Page 16: Oxygen Basic Compiler - documentation.help · Oxygen Basic (o2H) is a Just-In-Time compiler assembler, deployed in a single DLL that takes source code strings and returns executable

blocksblock,scope,skip,o2,(,

RELATED: proceduresmacros

'------

'MACROS

'======

macrocube(v)

v*v*v

endmacro

#definecube(v)v*v*v

defcube%1*%1*%1

%cube%1*%1*%1

$cube%1*%1*%1

'printcube3

'MACROMEMBERS

'=============

macromultiple(v)

macro.two(v)

v*v

endmacro

macro.three(v)

v*v*v

endmacro

macro.four(v)

v*v*v*v

endmacro

endmacro

printmultiple.four3

Page 17: Oxygen Basic Compiler - documentation.help · Oxygen Basic (o2H) is a Just-In-Time compiler assembler, deployed in a single DLL that takes source code strings and returns executable
Page 18: Oxygen Basic Compiler - documentation.help · Oxygen Basic (o2H) is a Just-In-Time compiler assembler, deployed in a single DLL that takes source code strings and returns executable

macrosmacro,#define,def,deff,%,$,

RELATED:macrofunctionsmacrooperatorsprocedures

Page 19: Oxygen Basic Compiler - documentation.help · Oxygen Basic (o2H) is a Just-In-Time compiler assembler, deployed in a single DLL that takes source code strings and returns executable

proceduresfunction,sub,method,gosub,

RELATED:macro

'----------

'PROCEDURES

'==========

'SUBROUTINES

floatv

gotoncube

cube:'subroutine

'printv*v*v

ret

ncube:

v=3:gosubcube

'SUBSANDFUNCTIONS

'==================

subcube(fasfloat,gasfloat)

g=f*f*f

endsub

dimfloata

cube2,a

'printa

functioncube(fasfloat)asfloat

function=f*f*f

endfunction

functioncube(fasfloat)asfloat

returnf*f*f

endfunction

'printcube2

'METHODS(INCLASSES)

'====================

classmultipliers

Page 20: Oxygen Basic Compiler - documentation.help · Oxygen Basic (o2H) is a Just-In-Time compiler assembler, deployed in a single DLL that takes source code strings and returns executable

methodcube(fasfloat)asfloat

returnf*f*f

endmethod

endclass

dimmultipliersm

'printm.cube4

'ALTERNATIVESYNTAX

'==================

'USEOF{..}

'===========

functioncube(fasfloat)asfloat{returnf*f*f}

functioncube(fasfloat)asfloat{

returnf*f*f

}

floatcube(fasfloat){

returnf*f*f

}

floatcube(floatf){

returnf*f*f

}

'printcube2

'PASSINGPARAMETERSBYREFERENCE

'===============================

dimasfloatf()={1,2,3,4,5}

functioncubes(fasfloat,byvalnasint)'defaultbyref

indexbase1

inti

fori=1ton

v=f[i]

printv*v*v

next

endfunction

functioncubes(float*f,intn)

Page 21: Oxygen Basic Compiler - documentation.help · Oxygen Basic (o2H) is a Just-In-Time compiler assembler, deployed in a single DLL that takes source code strings and returns executable

indexbase1

floatv

inti

fori=1ton

v=f[i]

printv*v*v

next

endfunction

'cubesf(2),3

'cubesf,countof(f)

'OPTIONALPARAMETERS

'===================

functioncubes(fasfloat,optionalbyvalnasint)

ifn=0thenn=1

indexbase1

floatv

inti

fori=1ton

v=f[i]

printv*v*v

next

endfunction

'cubesf(3)

'cubesf(3),1

'cubesfloat{1,2,3,4},countof'PASSINGLITERALDATASET

'DEFAULTPARAMETERS

'==================

functioncubes(float*f,intn=2)

indexbase1

floatv

inti

fori=1ton

v=f[i]

printv*v*v

next

endfunction

'cubesf(3)

'cubesf(3),2

Page 22: Oxygen Basic Compiler - documentation.help · Oxygen Basic (o2H) is a Just-In-Time compiler assembler, deployed in a single DLL that takes source code strings and returns executable

'ELLIPSIS...

'============

functioncuber(intn,...)

indexbase0

floatv

inti

fori=1ton

v=(int)param[i]

printv*v*v

next

endfunction

'cuber3,2,3,4

Page 23: Oxygen Basic Compiler - documentation.help · Oxygen Basic (o2H) is a Just-In-Time compiler assembler, deployed in a single DLL that takes source code strings and returns executable

conditionalsif,then,elseif,else,endif,

RELATED: selectionloops

'------------

'CONDITIONALS

'============

strings

inta=1,b=2

'SINGLELINEFORMAT

ifa>bthens="A>B"elses="A<=B"

'prints

'MULTI-LINEFORMAT

ifa>bthen

s="A>B"

elseifa=bthen

s="A=B"

else

s="A<B"

endif

'-----------------

'SYNTAXVARIATIONS

'=================

if(a>b){s="A>B"}elseif(a=b){s="A=B"}else{s="A<B"}

ifa>b{s="A>B"}elseifa=b{s="A=B"}else{s="A<B"}

ifa>b{

s="A>B"

}elseifa=b{

s="A=B"

}else{

s="A<B"

}

Page 24: Oxygen Basic Compiler - documentation.help · Oxygen Basic (o2H) is a Just-In-Time compiler assembler, deployed in a single DLL that takes source code strings and returns executable

print"A=1B=2

"s

Page 25: Oxygen Basic Compiler - documentation.help · Oxygen Basic (o2H) is a Just-In-Time compiler assembler, deployed in a single DLL that takes source code strings and returns executable

loopsdo,while,exit,continue,wend,enddo,

RELATED: iterationconditionals

'-----

'LOOPS

'=====

dima,b,c,daslong,sasstring

'SIMPLELOOPS

'------------

a=4

'

b=0

do

b+=1

ifb>athenexitdo

enddo'orenddo

b=0

do

b+=1

ifb>athenexitdo

loop

'-----------------

'CONDITIONALFORMS

'=================

b=0

whileb<=a

b+=1

endwhile'orendwhile

b=0

whileb<=a

b+=1

wend

b=0

whileb<=a{b+=1}

Page 26: Oxygen Basic Compiler - documentation.help · Oxygen Basic (o2H) is a Just-In-Time compiler assembler, deployed in a single DLL that takes source code strings and returns executable

b=0

do{b+=1}whileb<a

b=0

do{b+=1}untilb>=a

b=0

do

b+=1

loopwhileb<a

b=0

do

b+=1

loopuntilb>=a

b=0

do

b+=1

ifb<athencontinuedo

ifb<athenrepeatdo

ifb>=athenexitdo

ifb>=athenbreak

loop

b=0

do

b+=1

continuewhileb<a'if/when/while

continueuntilb>=a

repeatuntilb>=a

redountilb>=a

redountilnotb<a

exitwhenb>=a'if/when

exitwhennotb<a

breakwhenb>=a'if/when

enddo

print"ok"

Page 27: Oxygen Basic Compiler - documentation.help · Oxygen Basic (o2H) is a Just-In-Time compiler assembler, deployed in a single DLL that takes source code strings and returns executable

iterationfor,to,step,next,

RELATED: loops

'---------

'ITERATION

'=========

dima,b,c,d,iaslong

dimsasstring="QWERTY"

'checksumexample

b=0

fori=1tolen(s)

b+=asc(s,i)

next

b=0

fori=1tolen(s)step1

b+=asc(s,i)

next

b=0

fori=len(s)to1step-1

b+=asc(s,i)

next

'-----------------

'SYNTAXVARIATIONS

'=================

b=0

fori=1tolen(s)step1{

a=asc(s,i)

b+=a

}

b=0

fori=1,len(s),1{

a=asc(s,i)

b+=a

Page 28: Oxygen Basic Compiler - documentation.help · Oxygen Basic (o2H) is a Just-In-Time compiler assembler, deployed in a single DLL that takes source code strings and returns executable

}

b=0

for(i=1,i<=len(s),i++){

a=asc(s,i)

b+=a

}

#semicolonseparator

b=0

for(i=1;i<=len(s);i++){

a=asc(s,i)

b+=a

}

#semicoloncomment

b=0

for(i=1,i<=len(s),i++){

a=asc(s,i)

b+=a

}

defqu"'"

print"Checksumfor"qusqu"="b

Page 29: Oxygen Basic Compiler - documentation.help · Oxygen Basic (o2H) is a Just-In-Time compiler assembler, deployed in a single DLL that takes source code strings and returns executable

selectionselect,case,case,endselect,

RELATED: conditionals

'------

'SELECT

'======

dimaaslong,sasstring

a=3

'COMPACTFORM

'------------

selecta'selectcasea

case1:s="A=1"

case2:s="A=2"

case3:s="A=3"

caseelse:s="A>3"

endselect'endsel

'GENERALFORM

'------------

selecta

case1

s="A=1"

case2

s="A=2"

case3

s="A=3"

caseelse

s="A>3"

endselect

'------------------

'SYNTAXVARIATIONS

Page 30: Oxygen Basic Compiler - documentation.help · Oxygen Basic (o2H) is a Just-In-Time compiler assembler, deployed in a single DLL that takes source code strings and returns executable

'=================

selecta{

case1

s="A=1"

case2

s="A=2"

case3

s="A=3"

caseelse

s="A>3"

}

switcha{

case1

s="A=1"

break

case2

s="A=2"

break

case3

s="A=3"

break

caseelse

s="A>3"

break

}

'----------

'EXTENSIONS

'==========

selecta

case1

s="A=1"

case2

s="A=2"

case3

s="A=3"

case4,5,6

'

Page 31: Oxygen Basic Compiler - documentation.help · Oxygen Basic (o2H) is a Just-In-Time compiler assembler, deployed in a single DLL that takes source code strings and returns executable

case7to9

'

case10to<20

'

caseelse

s="A>3"

endselect

prints

Page 32: Oxygen Basic Compiler - documentation.help · Oxygen Basic (o2H) is a Just-In-Time compiler assembler, deployed in a single DLL that takes source code strings and returns executable

structurestype,

RELATED: classesclass

'--------------

'COMPOUNDTYPES

'==============

typecolor32

rasbyte

gasbyte

basbyte

aasbyte

=

rgbaaslong'UNION

endtype

'-------------

'DERIVEDTYPE:

'=============

typecolortext

txtasstring

cascolor32

endtype

dimtascolortext

t.txt=`Colorcode`

t.c.r=8

t.c.b=16

t.c.g=32

t.c.a=64

printt.txthext.c.rgba

'print"STRUCTURE:

'"structureofcolor32

Page 33: Oxygen Basic Compiler - documentation.help · Oxygen Basic (o2H) is a Just-In-Time compiler assembler, deployed in a single DLL that takes source code strings and returns executable

'-----------------

'SYNTAXVARIATIONS

'=================

typecolor32

byter

byteg

byteb

bytea

=

longrgba'UNION

endtype

typecolor32

byter,g,b,a

=

longrgba'UNION

endtype

typecolor32byter,g,b,a=longrgba

typecolortextstringtxt,color32c

structcolor32{

byter,g,b,a

=

longrgba

}

typedefstruct_color32{

byter,g,b,a

=

longrgba

}color32,*pcolor32

typedefstruct_color32{

union{

struct{

byter,g,b,a

}

longrgba

}

}color32,*pcolor32

Page 34: Oxygen Basic Compiler - documentation.help · Oxygen Basic (o2H) is a Just-In-Time compiler assembler, deployed in a single DLL that takes source code strings and returns executable

'#recordofcolor32

'#recordof_color32

'#recordofcolortext

Page 35: Oxygen Basic Compiler - documentation.help · Oxygen Basic (o2H) is a Just-In-Time compiler assembler, deployed in a single DLL that takes source code strings and returns executable

classesclass,objects,oop,has,of,from,inherits,virtual,pure,com,new,del,

RELATED: structurestype

'-------

'CLASSES

'=======

'METHODS(INCLASSES)

'====================

classmultipliers

methodcube(fasfloat)asfloat

returnf*f*f

endmethod

endclass

dimmultipliersm

'printm.cube4

'ALTERNATIVESYNTAX

'==================

classmultipliers{

methodcube(fasfloat)asfloat{

returnf*f*f

}

}

dimmultipliersm

printm.cube4

Page 36: Oxygen Basic Compiler - documentation.help · Oxygen Basic (o2H) is a Just-In-Time compiler assembler, deployed in a single DLL that takes source code strings and returns executable

operatorsand,or,xor,=,:=,+,-,*,/,\,^,+=,-=,*=,/=,==,!=,<>,<,>,<=,>,>=,<=,and=,or=,xor=",&,|,&=,|=,&&,||,^^,&&=,||=,^^=,<<,>>,<<,>>>,

ACTION: changesthestateofanaccumulatorUSE: formulatingexpressions,inconjunctionwithoperandsEXAMPLE:

a*b+c/4

REMARKS: universalfeatureofmathsandprogramminglanguages

RELATED: types

Page 37: Oxygen Basic Compiler - documentation.help · Oxygen Basic (o2H) is a Just-In-Time compiler assembler, deployed in a single DLL that takes source code strings and returns executable

callingstdcall,cdecl,ms64,pascal,

ACTION: determineshowparametersarepassedonthestack,whenmakingacall

Page 38: Oxygen Basic Compiler - documentation.help · Oxygen Basic (o2H) is a Just-In-Time compiler assembler, deployed in a single DLL that takes source code strings and returns executable

voidUSE: specifyanulltypeEXAMPLE:

'Variables:

void*pv=getmemory(100*sizeoffloat)

...

freememorypv

'

'Infunctionheaders:

functionfoo(byrefvasvoid)asvoidptr

void*foo(void*v)

'Proceduresnotreturningavalue:

voidfoo()

'

REMARKS: Voidcannotbeuseddirectly.

RELATED: sysanytypes

Page 39: Oxygen Basic Compiler - documentation.help · Oxygen Basic (o2H) is a Just-In-Time compiler assembler, deployed in a single DLL that takes source code strings and returns executable

sbyteUSE: specifyasignedbytetype(8bitswide)EXAMPLE:

sbytex=-10

REMARKS: limitedtovaluesrangingfrom-128to127/0x80to0x7F

RELATED: types

Page 40: Oxygen Basic Compiler - documentation.help · Oxygen Basic (o2H) is a Just-In-Time compiler assembler, deployed in a single DLL that takes source code strings and returns executable

ubyteUSE: specifyabytetype(8bitswide)EXAMPLE:

ubytesemicolon=59

REMARKS: limitedtovalues0..255/0x00to0xFF

RELATED: types

Page 41: Oxygen Basic Compiler - documentation.help · Oxygen Basic (o2H) is a Just-In-Time compiler assembler, deployed in a single DLL that takes source code strings and returns executable

byteUSE: specifyabytetype(8bitswide)EXAMPLE:

bytecolon=58

REMARKS: limitedtovalues0..255/0x00to0xFF

RELATED: types

Page 42: Oxygen Basic Compiler - documentation.help · Oxygen Basic (o2H) is a Just-In-Time compiler assembler, deployed in a single DLL that takes source code strings and returns executable

stringACTION: returnsastringofcharactersUSE: string=string(length,character)EXAMPLE:

string=string(4,"a")

RESULT:s="aaaa"

RELATED: spacenulsasc

Page 43: Oxygen Basic Compiler - documentation.help · Oxygen Basic (o2H) is a Just-In-Time compiler assembler, deployed in a single DLL that takes source code strings and returns executable

string2USE: specifyastringtypewith16-bitcharacters,supportingunicodeEXAMPLE:

wstringsw

getfile"greek.txt",sw

REMARKS: stringsareautomaticallydestroyedwhenoutofscope.

RELATED: unictypes

Page 44: Oxygen Basic Compiler - documentation.help · Oxygen Basic (o2H) is a Just-In-Time compiler assembler, deployed in a single DLL that takes source code strings and returns executable

wstringUSE: specifyastringtypewith16-bitcharacters,supportingunicodeEXAMPLE:

wstringsw

getfile"greek.txt",sw

REMARKS: stringsareautomaticallydestroyedwhenoutofscope.

RELATED: unictypes

Page 45: Oxygen Basic Compiler - documentation.help · Oxygen Basic (o2H) is a Just-In-Time compiler assembler, deployed in a single DLL that takes source code strings and returns executable

bstringUSE: specifyabstringtypewith8-bitcharactersEXAMPLE:

bstrings="name:"

...

freess

REMARKS: bstringsmustbefreedbeforegoingoutofscope.

RELATED: bstring2types

Page 46: Oxygen Basic Compiler - documentation.help · Oxygen Basic (o2H) is a Just-In-Time compiler assembler, deployed in a single DLL that takes source code strings and returns executable

gstr_

Page 47: Oxygen Basic Compiler - documentation.help · Oxygen Basic (o2H) is a Just-In-Time compiler assembler, deployed in a single DLL that takes source code strings and returns executable

bstrUSE: specifyabstringtypewith8-bitcharactersEXAMPLE:

bstrs="name:"

...

freess

REMARKS: bstringsmustbefreedbeforegoingoutofscope.

RELATED: bstring2types

Page 48: Oxygen Basic Compiler - documentation.help · Oxygen Basic (o2H) is a Just-In-Time compiler assembler, deployed in a single DLL that takes source code strings and returns executable

bstring2USE: specifyabstringtypewith16-bitcharacters,supportingunicodeEXAMPLE:

bstring2sw

getfile"greek.txt",sw

...

freessw

REMARKS: bstringsmustbefreedbeforegoingoutofscope.

RELATED: bstringtypes

Page 49: Oxygen Basic Compiler - documentation.help · Oxygen Basic (o2H) is a Just-In-Time compiler assembler, deployed in a single DLL that takes source code strings and returns executable

charUSE: specifyastringofasciicharacters(8bitswide)EXAMPLE:

charw="world"

charbuf[1024]

buf=w

print"hello"+buf

REMARKS: similartoCchar,butisnotconflatedwithbytewhichisanumerictype

RELATED: wchartypes

Page 50: Oxygen Basic Compiler - documentation.help · Oxygen Basic (o2H) is a Just-In-Time compiler assembler, deployed in a single DLL that takes source code strings and returns executable

wcharUSE: specifyastringofwidecharacters(16bitswide)EXAMPLE:

wcharw="world"

wcharbuf[1024]

buf=w

printbuf

RELATED: chartypes

Page 51: Oxygen Basic Compiler - documentation.help · Oxygen Basic (o2H) is a Just-In-Time compiler assembler, deployed in a single DLL that takes source code strings and returns executable

cstr_

Page 52: Oxygen Basic Compiler - documentation.help · Oxygen Basic (o2H) is a Just-In-Time compiler assembler, deployed in a single DLL that takes source code strings and returns executable

asciizUSE: specifyastringofasciicharacters(8bitswide)EXAMPLE:

asciizw="world"

asciizbuf[1024]

buf=w

print"hello"+buf

REMARKS: similartoCchar,butisnotconflatedwithbytewhichisanumerictype

RELATED: wchartypes

Page 53: Oxygen Basic Compiler - documentation.help · Oxygen Basic (o2H) is a Just-In-Time compiler assembler, deployed in a single DLL that takes source code strings and returns executable

zstringUSE: specifyastringofasciicharacters(8bitswide)EXAMPLE:

zstringw="world"

zstringbuf[1024]

buf=w

print"hello"+buf

REMARKS: similartoCchar,butisnotconflatedwithbytewhichisanumerictype

RELATED: wchartypes

Page 54: Oxygen Basic Compiler - documentation.help · Oxygen Basic (o2H) is a Just-In-Time compiler assembler, deployed in a single DLL that takes source code strings and returns executable

zstring2USE: specifyastringofwidecharacters(16bitswide)EXAMPLE:

zstring2w="world"

zstring2buf[1024]

buf=w

printbuf

RELATED: chartypes

Page 55: Oxygen Basic Compiler - documentation.help · Oxygen Basic (o2H) is a Just-In-Time compiler assembler, deployed in a single DLL that takes source code strings and returns executable

asciiz2USE: specifyastringofwidecharacters(16bitswide)EXAMPLE:

asciiz2w="world"

asciiz2buf[1024]

buf=w

printbuf

RELATED: chartypes

Page 56: Oxygen Basic Compiler - documentation.help · Oxygen Basic (o2H) is a Just-In-Time compiler assembler, deployed in a single DLL that takes source code strings and returns executable

shortUSE: specifyashortinteger(16bitswide).Alsousedinconjunction

withothertypestohalvethebitwidthEXAMPLE:

shorta

shortintb

shortshortc'ansbyte

RELATED: longtypes

Page 57: Oxygen Basic Compiler - documentation.help · Oxygen Basic (o2H) is a Just-In-Time compiler assembler, deployed in a single DLL that takes source code strings and returns executable

wideUSE: specifyawidecharacterstring(16bitswide).Alsousedin

conjunctionwithothertypestodoublethebitwidthEXAMPLE:

wides

widecharsw

widefloatfw'adoubleprecisionfloat

RELATED: shorttypes

Page 58: Oxygen Basic Compiler - documentation.help · Oxygen Basic (o2H) is a Just-In-Time compiler assembler, deployed in a single DLL that takes source code strings and returns executable

longUSE: specifyalonginteger(32bitswide).Alsousedinconjunction

withothertypestodoublethebitwidthEXAMPLE:

longi

RELATED: shorttypes

Page 59: Oxygen Basic Compiler - documentation.help · Oxygen Basic (o2H) is a Just-In-Time compiler assembler, deployed in a single DLL that takes source code strings and returns executable

intUSE: specifyalongsignedinteger(32bitswide)EXAMPLE:

inti=0x7fffffff

RELATED: dwordtypes

Page 60: Oxygen Basic Compiler - documentation.help · Oxygen Basic (o2H) is a Just-In-Time compiler assembler, deployed in a single DLL that takes source code strings and returns executable

integerUSE: specifyalongsignedinteger(32bitswide)EXAMPLE:

integeri=0x7fffffff

RELATED: dwordtypes

Page 61: Oxygen Basic Compiler - documentation.help · Oxygen Basic (o2H) is a Just-In-Time compiler assembler, deployed in a single DLL that takes source code strings and returns executable

floatUSE: specifyafloatingpointvariable(32bitswide)EXAMPLE:

floatf=1/100

REMARKS: sameassingle

RELATED: singledoubleextendedtypes

Page 62: Oxygen Basic Compiler - documentation.help · Oxygen Basic (o2H) is a Just-In-Time compiler assembler, deployed in a single DLL that takes source code strings and returns executable

singleUSE: specifyafloatingpointvariable(32bitswide)EXAMPLE:

singlef=1/100

REMARKS: sameasfloat

RELATED: floatdoubleextendedtypes

Page 63: Oxygen Basic Compiler - documentation.help · Oxygen Basic (o2H) is a Just-In-Time compiler assembler, deployed in a single DLL that takes source code strings and returns executable

doubleUSE: specifyadoubleprecisionfloatingpointvariable(64bitswide)EXAMPLE:

doublef=1/3

RELATED: singlefloatextendedtypes

Page 64: Oxygen Basic Compiler - documentation.help · Oxygen Basic (o2H) is a Just-In-Time compiler assembler, deployed in a single DLL that takes source code strings and returns executable

extendedUSE: specifyanextendedprecisionfloatingpointvariable(80bitswide)EXAMPLE:

extendede=1/3

REMARKS: thistypeholdsthefullprecisionofthepentiumfloatinpointprocessor(FPU)

RELATED: singlefloatdoubletypes

Page 65: Oxygen Basic Compiler - documentation.help · Oxygen Basic (o2H) is a Just-In-Time compiler assembler, deployed in a single DLL that takes source code strings and returns executable

quadUSE: specifyadoubleprecisionsignedinteger(64bitswide)EXAMPLE:

quadq

REMARKS: Ina64bitsystem,theseareprocesseddirectlyontheCPU.Ina32bitsystem,quadsarepassedtotheFPUforprocessing

RELATED: qwordintshortsbytetypes

Page 66: Oxygen Basic Compiler - documentation.help · Oxygen Basic (o2H) is a Just-In-Time compiler assembler, deployed in a single DLL that takes source code strings and returns executable

wordUSE: specifyashortunsignedinteger(16bitswide)EXAMPLE:

wordw=0xA000

RELATED: shortintdwordtypes

Page 67: Oxygen Basic Compiler - documentation.help · Oxygen Basic (o2H) is a Just-In-Time compiler assembler, deployed in a single DLL that takes source code strings and returns executable

dwordUSE: specifyalongunsignedinteger(32bitswide)EXAMPLE:

dwordui=0xA0000000

RELATED: wordlongintquadtypes

Page 68: Oxygen Basic Compiler - documentation.help · Oxygen Basic (o2H) is a Just-In-Time compiler assembler, deployed in a single DLL that takes source code strings and returns executable

ulongUSE: specifyalongunsignedinteger(32bitswide)EXAMPLE:

ulongu=0xA0000000

REMARKS: sameasuint

RELATED: uintwordtypes

Page 69: Oxygen Basic Compiler - documentation.help · Oxygen Basic (o2H) is a Just-In-Time compiler assembler, deployed in a single DLL that takes source code strings and returns executable

uintUSE: specifyalongunsignedinteger(32bitswide)EXAMPLE:

uintu=0xA0000000

REMARKS: sameasdwordandulong

RELATED: dwordwordbytetypes

Page 70: Oxygen Basic Compiler - documentation.help · Oxygen Basic (o2H) is a Just-In-Time compiler assembler, deployed in a single DLL that takes source code strings and returns executable

qwordUSE: specifya64bitoperandinassemblycodeEXAMPLE:

fldqwordd

REMARKS: Onlyusedinassemblycode,notBasic.

RELATED: integerquadtypes

Page 71: Oxygen Basic Compiler - documentation.help · Oxygen Basic (o2H) is a Just-In-Time compiler assembler, deployed in a single DLL that takes source code strings and returns executable

anyUSE: specifyaparameterofuncertaintype,nominallyasignedinteger

ofsystemwidth(32/64bitswide)EXAMPLE:

functionf(any*a){...}

REMARKS: Parameterofanytypemaybepassedby-reference.LikeCvoid*.

RELATED: systypes

Page 72: Oxygen Basic Compiler - documentation.help · Oxygen Basic (o2H) is a Just-In-Time compiler assembler, deployed in a single DLL that takes source code strings and returns executable

sysUSE: specifyasignedintegerofsystemwidth(32/64bitswide)EXAMPLE:

sysi=42

REMARKS: thistypeisalwayswideenoughtoholdapointer.

RELATED: anyintquadtypes

Page 73: Oxygen Basic Compiler - documentation.help · Oxygen Basic (o2H) is a Just-In-Time compiler assembler, deployed in a single DLL that takes source code strings and returns executable

booleanUSE: specifyavariabletoholdBooleantrue/falsestatesEXAMPLE:

booleant=true

ifnottthen...

REMARKS: NotionallyaBooleantype,butinreality.itisansbyte(8bitsignedinteger

RELATED: boolbyteintanytypesbooleantypes

Page 74: Oxygen Basic Compiler - documentation.help · Oxygen Basic (o2H) is a Just-In-Time compiler assembler, deployed in a single DLL that takes source code strings and returns executable

boolUSE: specifyavariabletoholdBooleantrue/falsestatesEXAMPLE:

boolt=true

ifnottthen...

REMARKS: NotionallyaBooleantype,butinreality.itisa32bitsignedinteger,asinC

RELATED: anytypesbooleaninttypes

Page 75: Oxygen Basic Compiler - documentation.help · Oxygen Basic (o2H) is a Just-In-Time compiler assembler, deployed in a single DLL that takes source code strings and returns executable

dimACTION: defineasetofvariablesUSE: createvariablesandarraysofvariableswithoptionalinitialvaluesEXAMPLE:

dimasstrings="HelloWorld"

RELATED: redimletvar

Page 76: Oxygen Basic Compiler - documentation.help · Oxygen Basic (o2H) is a Just-In-Time compiler assembler, deployed in a single DLL that takes source code strings and returns executable

localACTION: definealocalsetofvariablesEXAMPLE:

localstrings

RELATED: dimstatic

Page 77: Oxygen Basic Compiler - documentation.help · Oxygen Basic (o2H) is a Just-In-Time compiler assembler, deployed in a single DLL that takes source code strings and returns executable

staticACTION: defineastaticsetofvariables,(persistantbutinvisibleoutsidthe

block)EXAMPLE:

staticstrings

RELATED: dimlocal

Page 78: Oxygen Basic Compiler - documentation.help · Oxygen Basic (o2H) is a Just-In-Time compiler assembler, deployed in a single DLL that takes source code strings and returns executable

typeACTION: defineacompoundvariabletypeEXAMPLE:

'typergbacolor

redasbyte

greenasbyte

blueasbyte

alphaasbyte

endtype

RELATED: typedefstructclass

Page 79: Oxygen Basic Compiler - documentation.help · Oxygen Basic (o2H) is a Just-In-Time compiler assembler, deployed in a single DLL that takes source code strings and returns executable

structACTION: defineacompoundvariabletype(CSyntax)EXAMPLE:

structrgbacolor

{

redasbyte

greenasbyte

blueasbyte

alphaasbyte

}

RELATED: typetypedefclass

Page 80: Oxygen Basic Compiler - documentation.help · Oxygen Basic (o2H) is a Just-In-Time compiler assembler, deployed in a single DLL that takes source code strings and returns executable

typedefACTION: defineasetoftypes(Csyntax)USE: createtypedefinitionsforcreatingothertypesEXAMPLE:

'typedefDouble*pDouble

RELATED: typestructclassunionenum

Page 81: Oxygen Basic Compiler - documentation.help · Oxygen Basic (o2H) is a Just-In-Time compiler assembler, deployed in a single DLL that takes source code strings and returns executable

includeACTION: includesourcecodefromanotherfileUSE: usedforincludingheaderfilesandotherunitsofsourcecodeEXAMPLE:

#include"rtl32.inc"

REMARKS: includeand#includearethesame

RELATED: includepathembedfile

Page 82: Oxygen Basic Compiler - documentation.help · Oxygen Basic (o2H) is a Just-In-Time compiler assembler, deployed in a single DLL that takes source code strings and returns executable

#includeACTION: includesourcecodefromanotherfileUSE: usedforincludingheaderfilesandotherunitsofsourcecodeEXAMPLE:

#include"rtl32.inc"

REMARKS: includeand#includearethesame

RELATED: includepathembedfile

Page 83: Oxygen Basic Compiler - documentation.help · Oxygen Basic (o2H) is a Just-In-Time compiler assembler, deployed in a single DLL that takes source code strings and returns executable

includepathACTION: defineafilepathforsourcefilesspecifiedbyinclude.RELATED: includelibrarypath

Page 84: Oxygen Basic Compiler - documentation.help · Oxygen Basic (o2H) is a Just-In-Time compiler assembler, deployed in a single DLL that takes source code strings and returns executable

$ACTION: defineanequate(whichcanbeusedasconstants)RELATED: equatesmacros#define.#def.def

Page 85: Oxygen Basic Compiler - documentation.help · Oxygen Basic (o2H) is a Just-In-Time compiler assembler, deployed in a single DLL that takes source code strings and returns executable

%ACTION: defineanequate(whichcanbeusedasconstants)RELATED: equatesmacros#define.#def.def

Page 86: Oxygen Basic Compiler - documentation.help · Oxygen Basic (o2H) is a Just-In-Time compiler assembler, deployed in a single DLL that takes source code strings and returns executable

defACTION: definealowlevelmacroEXAMPLE:

''DEFINEMACRO:

REMARKS: defand#defarethesame

RELATED: macro#definedeff

Page 87: Oxygen Basic Compiler - documentation.help · Oxygen Basic (o2H) is a Just-In-Time compiler assembler, deployed in a single DLL that takes source code strings and returns executable

#defACTION: definealowlevelmacroEXAMPLE:

''DEFINEMACRO:

REMARKS: defand#defarethesame

RELATED: macro#definedeff

Page 88: Oxygen Basic Compiler - documentation.help · Oxygen Basic (o2H) is a Just-In-Time compiler assembler, deployed in a single DLL that takes source code strings and returns executable

macroACTION: defineahighlevelmacroUSE: manyuses.Oftenapseudofunctionforproducinginlinecode

insteadofacall

'------

'MACROS

'======

macrocube(v)

v*v*v

endmacro

#definecube(v)v*v*v

defcube%1*%1*%1

%cube%1*%1*%1

$cube%1*%1*%1

'printcube3

'MACROMEMBERS

'=============

macromultiple(v)

macro.two(v)

v*v

endmacro

macro.three(v)

v*v*v

endmacro

macro.four(v)

v*v*v*v

endmacro

endmacro

printmultiple.four3

Page 89: Oxygen Basic Compiler - documentation.help · Oxygen Basic (o2H) is a Just-In-Time compiler assembler, deployed in a single DLL that takes source code strings and returns executable

RELATED:macros#define#defdefdeff

Page 90: Oxygen Basic Compiler - documentation.help · Oxygen Basic (o2H) is a Just-In-Time compiler assembler, deployed in a single DLL that takes source code strings and returns executable

#defineACTION: defineamacro(Csyntax)USE: CpreprocessorstatementsEXAMPLE:

#defineX32

RELATED: macrosmacrodef#ifdef#ifndef

Page 91: Oxygen Basic Compiler - documentation.help · Oxygen Basic (o2H) is a Just-In-Time compiler assembler, deployed in a single DLL that takes source code strings and returns executable

blockACTION: startablockRELATED: blocksscopeexitrepeatdowhileifselect

Page 92: Oxygen Basic Compiler - documentation.help · Oxygen Basic (o2H) is a Just-In-Time compiler assembler, deployed in a single DLL that takes source code strings and returns executable

scopeACTION: startascopeUSE: createablockwherevariablesandfunctionsmaybelocally

definedEXAMPLE:

:

sysi=4

scope

sysi=8

'print"innerscopei="i

endscope

'-----------------

'EQUIVALENTSYNTAX

'=================

scope

{

sysi=8

'print"innerscopei="i

}

(

sysi=8

'print"innerscopei="i

)

print"outerscopei="i'i=4

REMARKS: whenthescopeendsanydefinitionscreatedwithinthescopewillbeforgotten.

RELATED: blocksblocknamespace

Page 93: Oxygen Basic Compiler - documentation.help · Oxygen Basic (o2H) is a Just-In-Time compiler assembler, deployed in a single DLL that takes source code strings and returns executable

o2ACTION: startablockofo2machinecodenotationUSE: insertinginlinemachinecodeandotherbinarydata.directuseof

o2language(usedbytheo2linker)EXAMPLE:

o2b800010000'machinecodeformoveax,256

RELATED: blocks

Page 94: Oxygen Basic Compiler - documentation.help · Oxygen Basic (o2H) is a Just-In-Time compiler assembler, deployed in a single DLL that takes source code strings and returns executable

deffACTION: createanassemblycodemacrofortheFPU(metatype-17)USE: tocreatefloatingpointmathsfunctionsEXAMPLE:

deffsinefsin

REMARKS: DeffmacrosmakeuseoftheFPU.Allfloatfunctionsaredefinedthisway.Thesearenon-recursivemacrosandtakenomacroarguments.TheexpressionparserisFPU-awareandtakescareofpassingparametersontotheFPUstack.

RELATED: macrosdef#definemacrosincos

Page 95: Oxygen Basic Compiler - documentation.help · Oxygen Basic (o2H) is a Just-In-Time compiler assembler, deployed in a single DLL that takes source code strings and returns executable

macrofunctionsUSE: invokemulti-linemacroswithinexpressions

'USINGMACROFUNCTIONS

'2DARRAYWITHBOUNDARYCLIPPING

indexbase0

intpix[800*600]

'

'SINGLE-LINEMACROFUNCTION

'macropix2d(x,y)pix(y*800+x)

'

'MULTI-LINEMACRORETURNINGAUNIQUEVARIABLE

'

macropix2dint*(v,x,y,vv)

=============================

'vpixelpointersupportingread/write

'xhorizontalcoordinate

'yverticalcoodinate

'vvsinkpixel

ifx>=0andx<800andy>=0andy<600

@v=@pix(y*800+x)

else

intvv=0xffffffff'valuewhenoutofbounds

@v=@vv

endif

endmacro

'

'TEST

pix2d(1,20)=0xaabbccdd

printhexpix2d(1,20)

printhexpix2d(800,10)

REMARKS: implementsin-linefunctions

RELATED: macrosmacrooperators

Page 96: Oxygen Basic Compiler - documentation.help · Oxygen Basic (o2H) is a Just-In-Time compiler assembler, deployed in a single DLL that takes source code strings and returns executable

macrooperatorsUSE: encodeoperatorsetsfordifferenttypes(UDTs)

'---------------

'MACROOPERATORS

'===============

'PARTIALDEMO

typevector3f

floatx,y,z

endtype

macrovector3f_op

macro."save"(a,acc)

a.x=acc.x

a.y=acc.y

a.z=acc.z

endmacro

macro."load"(acc,a)

acc.x=a.x

acc.y=a.y

acc.z=a.z

endmacro

macro."neg"(acc,a)

acc.x=-a.x

acc.y=-a.y

acc.z=-a.z

endmacro

macro."+"(acc,a)

acc.x+=a.x

acc.y+=a.y

acc.z+=a.z

endmacro

macro."-"(acc,a)

acc.x-=a.x

acc.y-=a.y

acc.z-=a.z

endmacro

macro."*"(acc,a)

acc.x*=a.x

acc.y*=a.y

acc.z*=a.z

endmacro

Page 97: Oxygen Basic Compiler - documentation.help · Oxygen Basic (o2H) is a Just-In-Time compiler assembler, deployed in a single DLL that takes source code strings and returns executable

macro."/"(acc,a)

acc.x/=a.x

acc.y/=a.y

acc.z/=a.z

endmacro

'

macro."str"string(out,a)'COREFUNCTIONS

out=str(a.x)+","+str(a.y)+","+str(a.z)

endmacro

'

endmacro

'TESTS

'=====

'#recordof"r.txt"vector3f_op

dimvector3fA={1,2,3}

dimvector3fB={10,20,30}

dimvector3fC={10,100,1000}

printstr(A)

printstr(A+B)

printstr(C*(A+B))

REMARKS: implementingoperatorsforcompundtypes:vectors,complexnumbers,matrices,etc.

RELATED: macrosmacrofunctions

Page 98: Oxygen Basic Compiler - documentation.help · Oxygen Basic (o2H) is a Just-In-Time compiler assembler, deployed in a single DLL that takes source code strings and returns executable

functionACTION: defineafunctionEXAMPLE:

functiontriple(iasint)asint

returni*3

endfunction

RELATED: proceduressubmethod

Page 99: Oxygen Basic Compiler - documentation.help · Oxygen Basic (o2H) is a Just-In-Time compiler assembler, deployed in a single DLL that takes source code strings and returns executable

subACTION: defineasub.(likeafunctionbutnotreturningavalue)EXAMPLE:

subtriple(iasint,jasint)

j=i*3

endsub

RELATED: proceduresfunctionmethod

Page 100: Oxygen Basic Compiler - documentation.help · Oxygen Basic (o2H) is a Just-In-Time compiler assembler, deployed in a single DLL that takes source code strings and returns executable

methodACTION: defineamethod.(afunctionorsubforobjects)EXAMPLE:

methodtriple(iasint)asint

returni*3

endmethod

RELATED: proceduresfunctionsub

Page 101: Oxygen Basic Compiler - documentation.help · Oxygen Basic (o2H) is a Just-In-Time compiler assembler, deployed in a single DLL that takes source code strings and returns executable

gosubACTION: callalabelledsubroutineUSE: invokelocalsubroutinesinsideaprocedure

'%filename"t.exe"

'usesrtl64

functionf()

inta=42

intb

'gosubg

gosubgwhena>0

printb

return

'

g:

b=a/2

ret

'

endfunction

f

RELATED: procedurescallgoto

Page 102: Oxygen Basic Compiler - documentation.help · Oxygen Basic (o2H) is a Just-In-Time compiler assembler, deployed in a single DLL that takes source code strings and returns executable

ifACTION: startaconditionalblockwithatestUSE: conditionalexecutionEXAMPLE:

ifa<bthena=b

RELATED: conditionalsthenelseelseifendifwhile

Page 103: Oxygen Basic Compiler - documentation.help · Oxygen Basic (o2H) is a Just-In-Time compiler assembler, deployed in a single DLL that takes source code strings and returns executable

thenACTION: startstheconditionalblockwherethepriortestismet.USE: conditionalexecutionEXAMPLE:

ifa>bthenprinta

RELATED: conditionalsifelseifendif

Page 104: Oxygen Basic Compiler - documentation.help · Oxygen Basic (o2H) is a Just-In-Time compiler assembler, deployed in a single DLL that takes source code strings and returns executable

elseifACTION: makeanalternativetestifthepreviousconditionwasnotmet.USE: conditionalexecutionRELATED: conditionalsifelseendif

Page 105: Oxygen Basic Compiler - documentation.help · Oxygen Basic (o2H) is a Just-In-Time compiler assembler, deployed in a single DLL that takes source code strings and returns executable

elseACTION: startsthealternativeblockwherenoneofthepriorconditionsare

metUSE: conditionalexecutionEXAMPLE:

ifa>bthenprintaelseprintb

RELATED: conditionalsifelseifendif

Page 106: Oxygen Basic Compiler - documentation.help · Oxygen Basic (o2H) is a Just-In-Time compiler assembler, deployed in a single DLL that takes source code strings and returns executable

endifendifACTION: endtheconditionalblockUSE: conditionalexecutionEXAMPLE:

ifa>bthen

a=b

endif

RELATED: conditionalsifthenelseifelseendif

Page 107: Oxygen Basic Compiler - documentation.help · Oxygen Basic (o2H) is a Just-In-Time compiler assembler, deployed in a single DLL that takes source code strings and returns executable

doACTION: startablockforrepetition(looping)EXAMPLE:

a=0

do

'...

a+=1:ifa=4thenexitdo

enddo

RESULT:a=4'4loops

RELATED: loopswhilecontinueexitenddoloop

Page 108: Oxygen Basic Compiler - documentation.help · Oxygen Basic (o2H) is a Just-In-Time compiler assembler, deployed in a single DLL that takes source code strings and returns executable

whileACTION: startablockforconditionalrepetitionEXAMPLE:

a=0

whilea<4

a+=1

wend

RESULT:a=4'4loops

REMARKS: whileidacombinationofdoandif¬.

RELATED: loopsdocontinueexitwendenddo

Page 109: Oxygen Basic Compiler - documentation.help · Oxygen Basic (o2H) is a Just-In-Time compiler assembler, deployed in a single DLL that takes source code strings and returns executable

exitACTION: exitadowhilefor(...)blockimmediatelyUSE: leavealoop,usuallyafteraconditionhasbeenmetEXAMPLE:

a=0:b=1

do

a+=1

ifa>4thenexitdo

b+=b

enddo

RESULT:a=5:b=16

REMARKS: Alsousedtoexitlow-levelnestingblocks.

RELATED: loopsdowhilecontinuerepeat

Page 110: Oxygen Basic Compiler - documentation.help · Oxygen Basic (o2H) is a Just-In-Time compiler assembler, deployed in a single DLL that takes source code strings and returns executable

continueACTION: gobacktothebeginningofado,whileorforblockUSE: to"shortcircuit"aloopREMARKS: continuedoandcontinuewhilewillloopbacktothe

nearestdoorwhile¬atthesamenestinglevel.

RELATED: loopsdowhileforbreakexitwendenddorepeat

Page 111: Oxygen Basic Compiler - documentation.help · Oxygen Basic (o2H) is a Just-In-Time compiler assembler, deployed in a single DLL that takes source code strings and returns executable

wendendwhile,loopACTION: endawhileblockUSE: see:whileRELATED: loopsdowhilecontinueexit

Page 112: Oxygen Basic Compiler - documentation.help · Oxygen Basic (o2H) is a Just-In-Time compiler assembler, deployed in a single DLL that takes source code strings and returns executable

enddoenddo,loopACTION: endadorepeatingblockUSE: see:doRELATED: loopswhiledoloopcontinueexit

Page 113: Oxygen Basic Compiler - documentation.help · Oxygen Basic (o2H) is a Just-In-Time compiler assembler, deployed in a single DLL that takes source code strings and returns executable

forACTION: startaniterationblockRELATED: iterationtostepnext

Page 114: Oxygen Basic Compiler - documentation.help · Oxygen Basic (o2H) is a Just-In-Time compiler assembler, deployed in a single DLL that takes source code strings and returns executable

toACTION: specifylimitofaniterationRELATED: iterationforstepnext

Page 115: Oxygen Basic Compiler - documentation.help · Oxygen Basic (o2H) is a Just-In-Time compiler assembler, deployed in a single DLL that takes source code strings and returns executable

stepACTION: specifyincrementofaniterationUSE: foriterator=starttoendstepstepincrementEXAMPLE:

fori=1to10step2:...:next

RESULT:iincreeasesby2witheachcycle:13579

RELATED: iterationfortonext

Page 116: Oxygen Basic Compiler - documentation.help · Oxygen Basic (o2H) is a Just-In-Time compiler assembler, deployed in a single DLL that takes source code strings and returns executable

nextACTION: enditerationblockRELATED: iterationfortostep

Page 117: Oxygen Basic Compiler - documentation.help · Oxygen Basic (o2H) is a Just-In-Time compiler assembler, deployed in a single DLL that takes source code strings and returns executable

selectACTION: StartaCaseblock(Cstyle)RELATED: selectioncaseendselend

Page 118: Oxygen Basic Compiler - documentation.help · Oxygen Basic (o2H) is a Just-In-Time compiler assembler, deployed in a single DLL that takes source code strings and returns executable

caseACTION: specifyacasetomatchfollowedbyactionstoperformRELATED: selectionselectendselend

Page 119: Oxygen Basic Compiler - documentation.help · Oxygen Basic (o2H) is a Just-In-Time compiler assembler, deployed in a single DLL that takes source code strings and returns executable

classACTION: defineaclass(strucureandmethodsforobjects)EXAMPLE:

''DEFINECLASS

'

classrgbacolor

redasbyte

greenasbyte

blueasbyte

alphaasbyte

'

methodin(sysr,sysg,sysb,sysa)

red=r:green=g:blue=b:alpha=a

endmethod

'

endclass

RELATED: classestypetypedefstruct

Page 120: Oxygen Basic Compiler - documentation.help · Oxygen Basic (o2H) is a Just-In-Time compiler assembler, deployed in a single DLL that takes source code strings and returns executable

hasEXAMPLE:

classperson

hasmind

REMARKS: 'has'isusedwhentheclassisderivedfrommorethanasingleparentalclass.ie:multipleinheritance.'has'maybeomitted.Itissufficienttoprovidetheclass/typenamewithoutthisqualifier.

RELATED: offromextendsclassclasses

Page 121: Oxygen Basic Compiler - documentation.help · Oxygen Basic (o2H) is a Just-In-Time compiler assembler, deployed in a single DLL that takes source code strings and returns executable

ofREMARKS: 'of',and'from'andextendsareequivalent.They

indicatederivationfromasingleparentalclass.COMinterfacesussingleinheritance

RELATED: hasclassclasses

Page 122: Oxygen Basic Compiler - documentation.help · Oxygen Basic (o2H) is a Just-In-Time compiler assembler, deployed in a single DLL that takes source code strings and returns executable

fromREMARKS: 'of',and'from'andextendsareequivalent.They

indicatederivationfromasingleparentalclass.COMinterfacesussingleinheritance

RELATED: hasclassclasses

Page 123: Oxygen Basic Compiler - documentation.help · Oxygen Basic (o2H) is a Just-In-Time compiler assembler, deployed in a single DLL that takes source code strings and returns executable

virtualREMARKS: objectsofvirtualclassesareusuallycreatedbysome

kindofserverorclassfactory.Theclientonlyreceivesareference(pointer)totheobjectfromtheserverandonlyknowshowtoinvokeitsmethods.Itassumesnoknowledgeofitsinnerworkings.

RELATED: comexternalexportclassexterncomclass

Page 124: Oxygen Basic Compiler - documentation.help · Oxygen Basic (o2H) is a Just-In-Time compiler assembler, deployed in a single DLL that takes source code strings and returns executable

comREMARKS: COMisaprotocolusedbyMicrosofttoprovideObjectinterfaces.

ClasseswiththisattributeareconsideredVirtual.

RELATED: virtualexternalexportclassofinheritsexternvirtualclass

Page 125: Oxygen Basic Compiler - documentation.help · Oxygen Basic (o2H) is a Just-In-Time compiler assembler, deployed in a single DLL that takes source code strings and returns executable

newACTION: createadynamicobjectandcallitsconstructormethod.USE: tocreateandinitialisepersistentobjectsEXAMPLE:

newshapecuboid1,1,1

RELATED: classesdelredimdim

Page 126: Oxygen Basic Compiler - documentation.help · Oxygen Basic (o2H) is a Just-In-Time compiler assembler, deployed in a single DLL that takes source code strings and returns executable

delACTION: Calladynamicobject'sdestructormethodanddisallocateits

memoryblock.USE: todeletedynamicobjectsEXAMPLE:

delcuboid

REMARKS: 'del'mayalsobeusedtodeletethecontentofindividualstringsandbstrings.Stringsaresettonull;thecontentsarereleasedandremovedfromthegarbagecollector'slists.

RELATED: classesnew

Page 127: Oxygen Basic Compiler - documentation.help · Oxygen Basic (o2H) is a Just-In-Time compiler assembler, deployed in a single DLL that takes source code strings and returns executable

and&REMARKS: bitwiseoperator

RELATED: andorxoroperators

Page 128: Oxygen Basic Compiler - documentation.help · Oxygen Basic (o2H) is a Just-In-Time compiler assembler, deployed in a single DLL that takes source code strings and returns executable

or|REMARKS: bitwiseoperator

RELATED: andor=xoroperators

Page 129: Oxygen Basic Compiler - documentation.help · Oxygen Basic (o2H) is a Just-In-Time compiler assembler, deployed in a single DLL that takes source code strings and returns executable

xorREMARKS: bitwiseoperator

RELATED: andorxor=operators

Page 130: Oxygen Basic Compiler - documentation.help · Oxygen Basic (o2H) is a Just-In-Time compiler assembler, deployed in a single DLL that takes source code strings and returns executable

*ACTION: returntheintegervaluelocatedbytheaddresscontainedinthevariableUSE: readingwritingdata,usingpointersEXAMPLE:

inta=42

print@a'addressofa

sysb'sys'ensuresanintegerlargeenoughtoholdapointer

b=@a'assinaddressofatob

print*b'42

REMARKS: UnlikeC,pointerresolutionisnormallyhandledimplictly.

RELATED: @?strptraddr

Page 131: Oxygen Basic Compiler - documentation.help · Oxygen Basic (o2H) is a Just-In-Time compiler assembler, deployed in a single DLL that takes source code strings and returns executable

and=&=REMARKS: bitwiseassignoperator

RELATED: andorxoroperators

Page 132: Oxygen Basic Compiler - documentation.help · Oxygen Basic (o2H) is a Just-In-Time compiler assembler, deployed in a single DLL that takes source code strings and returns executable

or=|=REMARKS: bitwiseassignoperator

RELATED: andorxoroperators

Page 133: Oxygen Basic Compiler - documentation.help · Oxygen Basic (o2H) is a Just-In-Time compiler assembler, deployed in a single DLL that takes source code strings and returns executable

&&REMARKS: logicaloperator

RELATED: &&||^^operators

Page 134: Oxygen Basic Compiler - documentation.help · Oxygen Basic (o2H) is a Just-In-Time compiler assembler, deployed in a single DLL that takes source code strings and returns executable

||REMARKS: logicaloperator

RELATED: &&||^^operators

Page 135: Oxygen Basic Compiler - documentation.help · Oxygen Basic (o2H) is a Just-In-Time compiler assembler, deployed in a single DLL that takes source code strings and returns executable

^^REMARKS: logicaloperator

RELATED: &&||^^operators

Page 136: Oxygen Basic Compiler - documentation.help · Oxygen Basic (o2H) is a Just-In-Time compiler assembler, deployed in a single DLL that takes source code strings and returns executable

&&=REMARKS: logicalassignoperator

RELATED: &&||^^operators

Page 137: Oxygen Basic Compiler - documentation.help · Oxygen Basic (o2H) is a Just-In-Time compiler assembler, deployed in a single DLL that takes source code strings and returns executable

||=REMARKS: logicalassignoperator

RELATED: &&||^^operators

Page 138: Oxygen Basic Compiler - documentation.help · Oxygen Basic (o2H) is a Just-In-Time compiler assembler, deployed in a single DLL that takes source code strings and returns executable

^^=REMARKS: logicalassignoperator

RELATED: &&||^^operators

Page 139: Oxygen Basic Compiler - documentation.help · Oxygen Basic (o2H) is a Just-In-Time compiler assembler, deployed in a single DLL that takes source code strings and returns executable

stdcallACTION: determineshowparametersarepassedonthestackUSE: declaringexternalfunctionsEXAMPLE:

!Sleeplib"kernel32.dll"stdcall(intmsec)

REMARKS: thisisthedefaultcallingconventionon32bitWindowsplatforms.

RELATED: callingcdeclms64pascal

Page 140: Oxygen Basic Compiler - documentation.help · Oxygen Basic (o2H) is a Just-In-Time compiler assembler, deployed in a single DLL that takes source code strings and returns executable

cdeclACTION: determineshowparametersarepassedonthestackUSE: declaringexternalfunctions,andvariadicfunctionsREMARKS: thisisacommoncallingconventionon32bitplatforms.Thestack

iscleanedupafterthecallbythecaller.

RELATED: callingcdeclms64pascalcallback

Page 141: Oxygen Basic Compiler - documentation.help · Oxygen Basic (o2H) is a Just-In-Time compiler assembler, deployed in a single DLL that takes source code strings and returns executable

ms64ACTION: determineshowparametersarepassedonthestackUSE: declaringexternalfunctions,andvariadicfunctionsREMARKS: thisisthedefaultWindowscallingconventionon64bitplatforms.

Thefirstfourparametersarepassedinregisters.Thestackiscleanedupafterthecallbythecaller.

RELATED: callingstdcallcdeclpascal

Page 142: Oxygen Basic Compiler - documentation.help · Oxygen Basic (o2H) is a Just-In-Time compiler assembler, deployed in a single DLL that takes source code strings and returns executable

pascalACTION: determineshowparametersarepassedonthestackUSE: declaringexternalfunctionsEXAMPLE:

!Sleeplib"kernel32.dll"stdcall(intmsec)

REMARKS: thisisalegacycallingconventionon32bitplatforms.

RELATED: callingstdcallcdeclms64

Page 143: Oxygen Basic Compiler - documentation.help · Oxygen Basic (o2H) is a Just-In-Time compiler assembler, deployed in a single DLL that takes source code strings and returns executable

spaceACTION: returnsastringofspacesUSE: string=spacelengthEXAMPLE:

s=space10

RESULT:s=""'10spaces(ascii32)

REMARKS: forwidestringsusestring(n,wchr32)instead

RELATED: nulsstringltrimrtrim

Page 144: Oxygen Basic Compiler - documentation.help · Oxygen Basic (o2H) is a Just-In-Time compiler assembler, deployed in a single DLL that takes source code strings and returns executable

nulsACTION: returnstheaddressofastringofnullcharactersgiventhelength.USE: string=nulslengthEXAMPLE:

s=nuls1000

RESULT:sisastringof1000nullcharacters

REMARKS: forwidestringsusestring(n,wchr0)instead

RELATED: spacestringnewsfreesgetmemory

Page 145: Oxygen Basic Compiler - documentation.help · Oxygen Basic (o2H) is a Just-In-Time compiler assembler, deployed in a single DLL that takes source code strings and returns executable

ascACTION: returnsasciiencodingofacharacterinastringUSE: AsciiCode=asc(String,CharacterPosition)EXAMPLE:

a=asc("ABCDEF",2)

RESULT:a=66'character='B'

RELATED: unicchrvallenstr

Page 146: Oxygen Basic Compiler - documentation.help · Oxygen Basic (o2H) is a Just-In-Time compiler assembler, deployed in a single DLL that takes source code strings and returns executable

unicACTION: returnsencodingofacharacterinawidestringUSE: uni=unic(String,CharacterPosition)EXAMPLE:

a=unic("ABCDEF",2)

RESULT:a=0x0042'character='B'

RELATED: ascwchrchrvallenstr

Page 147: Oxygen Basic Compiler - documentation.help · Oxygen Basic (o2H) is a Just-In-Time compiler assembler, deployed in a single DLL that takes source code strings and returns executable

redimACTION: createorresizeadynamicarray,preservingcontentswithinrangeUSE: extendorreduceanarraysizeatrun-timeEXAMPLE:

redimstrings(n)

REMARKS: toflushanarray'scontents,redimitwith0elementsfirst.Butavoiddoingthiswitharraysofstrings;theorphanedstringsarenotgarbage-collecteduntiltheendoftheprogram,andwillaccumulateoneachiterationwheretheredimreducesthenumberofelements.

RELATED: dimnew

Page 148: Oxygen Basic Compiler - documentation.help · Oxygen Basic (o2H) is a Just-In-Time compiler assembler, deployed in a single DLL that takes source code strings and returns executable

letACTION: definesavariableorobjectUSE: createanewvariableorindirectobjectEXAMPLE:

lets="thisisastring"

printtypeofs'result:'string'

REMARKS: Similartousing'dim'butthetypeisinferredfromtheassignedvalue.

RELATED: dimvar

Page 149: Oxygen Basic Compiler - documentation.help · Oxygen Basic (o2H) is a Just-In-Time compiler assembler, deployed in a single DLL that takes source code strings and returns executable

varACTION: defineasetofvariablesUSE: low-leveldimensioningofvariablesEXAMPLE:

varstrings,t,u(64),v

REMARKS: varisnormallyonlyusedinternally.itaccepts*forindirectvariablesand"at"forvariablemapping.Arraysarealsosupported.

RELATED: dim

Page 150: Oxygen Basic Compiler - documentation.help · Oxygen Basic (o2H) is a Just-In-Time compiler assembler, deployed in a single DLL that takes source code strings and returns executable

unionACTION: defineaunion(Csyntax)USE: allowsdifferentvariablestooccupythesamespace.EXAMPLE:

unionutype

{

byteb

shortw

longi

}

RESULT:v.b=42:v.w=42:v.i=42

REMARKS: aunionmayalsobenestedinsideatype.

RELATED: typedeftypestructclassenum

Page 151: Oxygen Basic Compiler - documentation.help · Oxygen Basic (o2H) is a Just-In-Time compiler assembler, deployed in a single DLL that takes source code strings and returns executable

enumACTION: createanenumerationUSE: assignanumericidentitytoaname

'------------

'ENUMERATIONS

'============

'SIMPLEENUMERATION

'==================

enumManyThings

shoes

ships

sealing_wax

cabbages

kings

endenum

defshow"%1:"%1

printshowcabbages

'ENUMERATIONFROMABASEVALUE

'=============================

enumManyThings

shoes=11

ships

sealing_wax

cabbages

kings

endenum

printshowships

'BITWISEENUMERATION

'===================

'1248163264...

enumbitManyThings

shoes

Page 152: Oxygen Basic Compiler - documentation.help · Oxygen Basic (o2H) is a Just-In-Time compiler assembler, deployed in a single DLL that takes source code strings and returns executable

ships

sealing_wax

cabbages

kings

endenum

'ENUMERATIONUSAGE

'=================

'DimasManyThingsmt

ManyThingsmt

mt=cabbages

printmt

REMARKS: Csyntaxissupportedforthisconstruct.Alsoenumbitassignsvalues1,2,4,8,16..insteadof0,1,2,3,4..

RELATED: typedefenum#define(%)

Page 153: Oxygen Basic Compiler - documentation.help · Oxygen Basic (o2H) is a Just-In-Time compiler assembler, deployed in a single DLL that takes source code strings and returns executable

embedfileACTION: specifiyafiletobeembeddedinthedatasectionUSE: storedatafileinaprogram,andgetapointertoit.EXAMPLE:

sysdat:embedfile"data.txt",dat

REMARKS: Textorbinaryfilesmaybeembeddedwiththiscommand.Thedataisread-only.Eitherasysorabstringvariablemaybeusedtoreferencethedata.Anupperlimitof255filescanbeembedded.

RELATED: includestrptrgetfile

Page 154: Oxygen Basic Compiler - documentation.help · Oxygen Basic (o2H) is a Just-In-Time compiler assembler, deployed in a single DLL that takes source code strings and returns executable

librarypathACTION: defineafilepathforDLLfilesUSE: tellsthecomputerwheretofindDynamicLinkLibrariesrequired

toruntheprogram.(SystemDLLsdonotrequirethis.)RELATED: libraryexternincludepath

Page 155: Oxygen Basic Compiler - documentation.help · Oxygen Basic (o2H) is a Just-In-Time compiler assembler, deployed in a single DLL that takes source code strings and returns executable

#ifdefACTION: includecodeifsymbolalreadydefinedUSE: toallowblocksofcodetobeincludedoromittedatcompiletimeEXAMPLE:

#ifdefMSWIN

#include"windows.inc"

#endif

RELATED: #if#elseif#endif

Page 156: Oxygen Basic Compiler - documentation.help · Oxygen Basic (o2H) is a Just-In-Time compiler assembler, deployed in a single DLL that takes source code strings and returns executable

#ifndefACTION: includecodeifsymbolalreadydefinedUSE: toallowblocksofcodetobeincludedoromittedatcompiletimeEXAMPLE:

#ifdefMSWIN

#include"windows.inc"

#endif

RELATED: #if#elseif#endif

Page 157: Oxygen Basic Compiler - documentation.help · Oxygen Basic (o2H) is a Just-In-Time compiler assembler, deployed in a single DLL that takes source code strings and returns executable

namespaceACTION: startanamspaceUSE: createaregionwheresymbolslocallydefinedEXAMPLE:

'

inti=1

'

namespaceaa

inti=10

namespacebb

inti=20

endnamespace

'

printi+aa::i+bb::i'31

'

namespacebb

printi'20

endnamespace

RELATED: scope

Page 158: Oxygen Basic Compiler - documentation.help · Oxygen Basic (o2H) is a Just-In-Time compiler assembler, deployed in a single DLL that takes source code strings and returns executable

sinACTION: returnsthesineofavaluegiveninradiansUSE: Sine=sin(Radians)EXAMPLE:

v=sin(pi/6)

RESULT:v=0.5

RELATED: asincostan

Page 159: Oxygen Basic Compiler - documentation.help · Oxygen Basic (o2H) is a Just-In-Time compiler assembler, deployed in a single DLL that takes source code strings and returns executable

cosACTION: returnscosinevalue(ratioofx/r)givenangleinradiansUSE: Cosine=cos(radians)EXAMPLE:

c=cos(pi/3)

RESULT:c=0.5

RELATED: sintan

Page 160: Oxygen Basic Compiler - documentation.help · Oxygen Basic (o2H) is a Just-In-Time compiler assembler, deployed in a single DLL that takes source code strings and returns executable

gotoACTION: jumptoaspecifiedlabelinthecodeEXAMPLE:

functioncube(fasfloat)asfloat{returnf*f*f}

RELATED: jmpgosub

Page 161: Oxygen Basic Compiler - documentation.help · Oxygen Basic (o2H) is a Just-In-Time compiler assembler, deployed in a single DLL that takes source code strings and returns executable

endACTION: markstheendofacodeblockUSE: terminatingvariousblockstructuresEXAMPLE:

ifa>bthen

b=a

endif

REMARKS: Anisolated'end'terminatestheprogram.

RELATED: blockscopeifdowhileselectfunctionsubmethodclassmacrodef

Page 162: Oxygen Basic Compiler - documentation.help · Oxygen Basic (o2H) is a Just-In-Time compiler assembler, deployed in a single DLL that takes source code strings and returns executable

loopenddo,enddoACTION: endadorepeatingblockUSE: see:doRELATED: loopsdocontinueexit

Page 163: Oxygen Basic Compiler - documentation.help · Oxygen Basic (o2H) is a Just-In-Time compiler assembler, deployed in a single DLL that takes source code strings and returns executable

breakACTION: exitaswitchblockordo/whileblockRELATED: caseswitchwhiledocontinue

Page 164: Oxygen Basic Compiler - documentation.help · Oxygen Basic (o2H) is a Just-In-Time compiler assembler, deployed in a single DLL that takes source code strings and returns executable

endselendselectACTION: endtheselectblockRELATED: selectionselectcase

Page 165: Oxygen Basic Compiler - documentation.help · Oxygen Basic (o2H) is a Just-In-Time compiler assembler, deployed in a single DLL that takes source code strings and returns executable

extendsREMARKS: 'of',and'from'andextendsareequivalent.They

indicatederivationfromasingleparentalclass.COMinterfacesussingleinheritance

RELATED: hasclassclasses

Page 166: Oxygen Basic Compiler - documentation.help · Oxygen Basic (o2H) is a Just-In-Time compiler assembler, deployed in a single DLL that takes source code strings and returns executable

externalREMARKS: functionswiththeexternalattributeexpecttobecalledfrom

proceduresexternaltoOxygen.Additionalregistermanagementisenlistedtosupportexternalcalls.

RELATED: externcomexportcallbackcomvirtualfunctionsubmethod

Page 167: Oxygen Basic Compiler - documentation.help · Oxygen Basic (o2H) is a Just-In-Time compiler assembler, deployed in a single DLL that takes source code strings and returns executable

exportREMARKS: procedureswiththisattributearevisibletoexternalcallers

whentheyarecompiledaspartofaDLL(DynamicLinkLibrary)

RELATED: externalfunctionsubextern

Page 168: Oxygen Basic Compiler - documentation.help · Oxygen Basic (o2H) is a Just-In-Time compiler assembler, deployed in a single DLL that takes source code strings and returns executable

externACTION: associatedeclaredprocedureswithacallingconventionand/ordllnameEXAMPLE:

externstdcalllib"kernel32.dll"

declarefunctionQueryPerformanceCounter(lpPerformanceCountasquad)assys

declarefunctionQueryPerformanceFrequency(lpPerformanceFrequencyasquad)assys

endextern

REMARKS: notetherisnoneedtouseanAliasinthesedeclarationsifyougivetheexactnameoftheproceduresintheiroriginalcase.

RELATED: liblibrarycalling

Page 169: Oxygen Basic Compiler - documentation.help · Oxygen Basic (o2H) is a Just-In-Time compiler assembler, deployed in a single DLL that takes source code strings and returns executable

xor=REMARKS: bitwiseassignoperator

RELATED: andorxoroperators

Page 170: Oxygen Basic Compiler - documentation.help · Oxygen Basic (o2H) is a Just-In-Time compiler assembler, deployed in a single DLL that takes source code strings and returns executable

@ACTION: returntheaddressofavariableUSE: readingwritingdataofvariablesandarraysofvariables,by

referenceEXAMPLE:

inta=42

print@a'addressofa

int*b'indirect(pointer)variable

@b=@a'coupledbyaddress

printb'42

REMARKS: UnlikeC,pointerresolutionishandledimplictly.Sothe@operatorisrequiredformanipulatingpointers.Itissimilartothe&operatorinC.

RELATED: *?strptraddr

Page 171: Oxygen Basic Compiler - documentation.help · Oxygen Basic (o2H) is a Just-In-Time compiler assembler, deployed in a single DLL that takes source code strings and returns executable

?ACTION: returntheintegervaluecontainedinthevariableUSE: castingvariablesasintegersEXAMPLE:

floatf=100

printhex(?f)'displaythehexadecimalformoffloatf

RELATED: cast*@strptraddr

Page 172: Oxygen Basic Compiler - documentation.help · Oxygen Basic (o2H) is a Just-In-Time compiler assembler, deployed in a single DLL that takes source code strings and returns executable

strptrACTION: returnastringpointerUSE: obtainbaseaddressofstringcontentsEXAMPLE:

strings="Hello"

sysa=strptrs

RELATED: typecodeofaddr

Page 173: Oxygen Basic Compiler - documentation.help · Oxygen Basic (o2H) is a Just-In-Time compiler assembler, deployed in a single DLL that takes source code strings and returns executable

addrACTION: resolveaddressofavariable(assembler)USE: loadaddressofavariabletoaregisterEXAMPLE:

sysa

addrecx,a

RELATED: @*?strptr

Page 174: Oxygen Basic Compiler - documentation.help · Oxygen Basic (o2H) is a Just-In-Time compiler assembler, deployed in a single DLL that takes source code strings and returns executable

ltrimACTION: returnsstringwithwhitespaceonthelefttrimmedoffUSE: string=rtrim(string)EXAMPLE:

s=ltrim"abc"

RESULT:s="abc"

RELATED: rtrimspacestrlcaseucase

Page 175: Oxygen Basic Compiler - documentation.help · Oxygen Basic (o2H) is a Just-In-Time compiler assembler, deployed in a single DLL that takes source code strings and returns executable

rtrimACTION: returnsstringwithwhitespaceontherighttrimmedoffUSE: string=rtrim(string)EXAMPLE:

s=rtrim"abc"

RESULT:s="abc"

RELATED: ltrimspacestrlcaseucase

Page 176: Oxygen Basic Compiler - documentation.help · Oxygen Basic (o2H) is a Just-In-Time compiler assembler, deployed in a single DLL that takes source code strings and returns executable

newsACTION: allocatesabstringofnullcharactersgiventhelengthinbytesUSE: bstring=newslengthEXAMPLE:

b=news1000

'...

freesb

RESULT:bcontainsaddressofastringof1000nulcharacters.Thenthestingisfreed

REMARKS: OxygenstringsareautomaticallyfreedbutBstringsmustbeexplicitlyfreedwhennolongerneeded.

RELATED: freesnulsspacebstringgetmemory

Page 177: Oxygen Basic Compiler - documentation.help · Oxygen Basic (o2H) is a Just-In-Time compiler assembler, deployed in a single DLL that takes source code strings and returns executable

freesACTION: deallocatesabstringUSE: freesbstringfreememoryEXAMPLE:

b=news1000

'...

freesb

RESULT:bcontainsaddressofastringof1000nulcharacters.Thenthestingisfreed

REMARKS: OxygenstringsareautomaticallyfreedbutBstringsmustbeexplicitlyfreedwhennolongerneeded.

RELATED: newsnulsfreememorygetmemory

Page 178: Oxygen Basic Compiler - documentation.help · Oxygen Basic (o2H) is a Just-In-Time compiler assembler, deployed in a single DLL that takes source code strings and returns executable

getmemoryACTION: allocateblockofmemoryandreturnitsbaseaddressUSE: address=getmemorybytesEXAMPLE:

m=getmemory8000

RELATED: freememorynewsfrees

Page 179: Oxygen Basic Compiler - documentation.help · Oxygen Basic (o2H) is a Just-In-Time compiler assembler, deployed in a single DLL that takes source code strings and returns executable

chrACTION: returnsstringof1characterofasciiencoding(0..255)USE: string=chr(AsciiValue)EXAMPLE:

s=chr(65)

RESULT:scontains"A"

RELATED: wchrascunicstring

Page 180: Oxygen Basic Compiler - documentation.help · Oxygen Basic (o2H) is a Just-In-Time compiler assembler, deployed in a single DLL that takes source code strings and returns executable

valACTION: returnsnumericvalueofstringUSE: value=valstringEXAMPLE:

v=val"2.5"

RESULT:v=2.5

RELATED: trhexasc

Page 181: Oxygen Basic Compiler - documentation.help · Oxygen Basic (o2H) is a Just-In-Time compiler assembler, deployed in a single DLL that takes source code strings and returns executable

lenACTION: returnslengthofstringincharatersUSE: length=len(string)EXAMPLE:

v=len("Hello")

RESULT:v=5

REMARKS: charactersmaybeoneortwobytes(widecharacters)

RELATED: stringspacemidsizeof

Page 182: Oxygen Basic Compiler - documentation.help · Oxygen Basic (o2H) is a Just-In-Time compiler assembler, deployed in a single DLL that takes source code strings and returns executable

strACTION: returnsstringrepresentationofnumberUSE: String=str(value)EXAMPLE:

s=str(-1.23456)'result:-1.23456

s=str(-1.23456,3)'result:-1.235

REMARKS: roundingisautomaticallyappliedbeforedecimalplacesaretruncated.

RELATED: hexval

Page 183: Oxygen Basic Compiler - documentation.help · Oxygen Basic (o2H) is a Just-In-Time compiler assembler, deployed in a single DLL that takes source code strings and returns executable

wchrACTION: returnswidestringofa2bytecharacter(encoding0..65535/

0xffff)USE: widestring=wchr(WideCharValue)EXAMPLE:

wstringws=wchr(65)

RESULT:wscontainsunicodecharacter0x0041

RELATED: unicascstring

Page 184: Oxygen Basic Compiler - documentation.help · Oxygen Basic (o2H) is a Just-In-Time compiler assembler, deployed in a single DLL that takes source code strings and returns executable

getfileACTION: copiesfilecontenttoastringUSE: String=getfileFileName:getfileFileName,StringEXAMPLE:

strings:getfile"t.txt",s

RESULT:scontainscontentof"t.txt"

RELATED: putfileprint

Page 185: Oxygen Basic Compiler - documentation.help · Oxygen Basic (o2H) is a Just-In-Time compiler assembler, deployed in a single DLL that takes source code strings and returns executable

libraryACTION: specifythenameofaDLLlibrarytoassociatewithasetof

proceduredeclarationsEXAMPLE:

lib"kernel32.dll"

RELATED: declare

Page 186: Oxygen Basic Compiler - documentation.help · Oxygen Basic (o2H) is a Just-In-Time compiler assembler, deployed in a single DLL that takes source code strings and returns executable

#ifACTION: includeblockofcodeifconditionsaremetRELATED: #else#elseif#endif

Page 187: Oxygen Basic Compiler - documentation.help · Oxygen Basic (o2H) is a Just-In-Time compiler assembler, deployed in a single DLL that takes source code strings and returns executable

#elseifACTION: includeblockofcodeifthesealternativeconditionsaremetRELATED: #if#else#endif#fi

Page 188: Oxygen Basic Compiler - documentation.help · Oxygen Basic (o2H) is a Just-In-Time compiler assembler, deployed in a single DLL that takes source code strings and returns executable

#endifACTION: endofconditionalcodeinclusionblockRELATED: #if#elseif

Page 189: Oxygen Basic Compiler - documentation.help · Oxygen Basic (o2H) is a Just-In-Time compiler assembler, deployed in a single DLL that takes source code strings and returns executable

asinACTION: returnsangleinradiansgiventheratioy/radiusUSE: angle=asin(YRRatio)EXAMPLE:

a=asin(0.5)

RESULT:a=pi/6

RELATED: sinacosatnatan

Page 190: Oxygen Basic Compiler - documentation.help · Oxygen Basic (o2H) is a Just-In-Time compiler assembler, deployed in a single DLL that takes source code strings and returns executable

tanACTION: returnsthetangentofavaluegiveninradiansUSE: tangent=tan(radians)EXAMPLE:

t=tan(a)

RESULT:t=ratioy/x

RELATED: atanatnsincos

Page 191: Oxygen Basic Compiler - documentation.help · Oxygen Basic (o2H) is a Just-In-Time compiler assembler, deployed in a single DLL that takes source code strings and returns executable

switchACTION: StartaCaseblock(Cstyle)RELATED: selectioncaseendselend

Page 192: Oxygen Basic Compiler - documentation.help · Oxygen Basic (o2H) is a Just-In-Time compiler assembler, deployed in a single DLL that takes source code strings and returns executable

libREMARKS: libmaybespecifiedintheDeclarestatementoritmaybe

specifiedinanexternstatement,referringtoanentiregroupofdeclarations.

RELATED: librarydeclareexternaliaslinkat

Page 193: Oxygen Basic Compiler - documentation.help · Oxygen Basic (o2H) is a Just-In-Time compiler assembler, deployed in a single DLL that takes source code strings and returns executable

castACTION: changeorspecifythetypeofavariabletemporarily,inanexpressionEXAMPLE:

floatf=100

printhex(cast(int)f)'displaythehexadecimalformoffloatf

printhex((int)f)'thesamewithoutusingthe'cast'word

RELATED: convert?union

Page 194: Oxygen Basic Compiler - documentation.help · Oxygen Basic (o2H) is a Just-In-Time compiler assembler, deployed in a single DLL that takes source code strings and returns executable

typecodeofACTION: returntypecodenumberofvariablesandliterals.USE: obtaindatafordiagnosticsorreflectiveprogrammingRELATED: typeofrecordofsizeofoffsetofspanofprototypeof#recordof

Page 195: Oxygen Basic Compiler - documentation.help · Oxygen Basic (o2H) is a Just-In-Time compiler assembler, deployed in a single DLL that takes source code strings and returns executable

lcaseACTION: returnslowercaseofstringUSE: string=lcase(string)EXAMPLE:

s=lcase"ABCDEF"

RESULT:s="abcdef"

RELATED: ucaseltrimrtrimasc

Page 196: Oxygen Basic Compiler - documentation.help · Oxygen Basic (o2H) is a Just-In-Time compiler assembler, deployed in a single DLL that takes source code strings and returns executable

ucaseACTION: returnsuppercaseofstringUSE: string=ucase(string)EXAMPLE:

s=ucase"abcdef"

RESULT:s="ABCDEF"

RELATED: lcaseltrimrtrimasc

Page 197: Oxygen Basic Compiler - documentation.help · Oxygen Basic (o2H) is a Just-In-Time compiler assembler, deployed in a single DLL that takes source code strings and returns executable

freememoryACTION: freepreviouslyallocatedmemoryblockUSE: freememoryaddressEXAMPLE:

freememorym

RELATED: getmemorynewsfrees

Page 198: Oxygen Basic Compiler - documentation.help · Oxygen Basic (o2H) is a Just-In-Time compiler assembler, deployed in a single DLL that takes source code strings and returns executable

hexACTION: returnshexadecimalstringrepresentationofintegerpartofnumberUSE: hexString=hex(value)EXAMPLE:

printhex(14.4)'result'E'

printhex(14.4,4)'result'000E'

RELATED: strval

Page 199: Oxygen Basic Compiler - documentation.help · Oxygen Basic (o2H) is a Just-In-Time compiler assembler, deployed in a single DLL that takes source code strings and returns executable

sizeofACTION: returnlengthofvariableelement(inbytes)USE: nbytes=sizeofvariableEXAMPLE:

n=sizeofa

RELATED: offsetofspanoftypeoftypecodeof

Page 200: Oxygen Basic Compiler - documentation.help · Oxygen Basic (o2H) is a Just-In-Time compiler assembler, deployed in a single DLL that takes source code strings and returns executable

putfileACTION: savesastringtoafileUSE: putfileFileName,StringEXAMPLE:

putfile"t.txt","Hello"

RESULT:Afilenamed"t.xt"iscreatedoroverwrittencontaining"Hello"

RELATED: getfileprint

Page 201: Oxygen Basic Compiler - documentation.help · Oxygen Basic (o2H) is a Just-In-Time compiler assembler, deployed in a single DLL that takes source code strings and returns executable

printACTION: DisplaysstringsandnumbersUSE: printString:printNumberEXAMPLE:

print"ABC":print123:print"ABC:"123"DEF:"456

RESULT:ABC

123

ABC:123DEF:456

REMARKS: stringscanbecombinedwithnumbersassysasthefirstelementisastring

RELATED: valstrhexputfilegetfile

Page 202: Oxygen Basic Compiler - documentation.help · Oxygen Basic (o2H) is a Just-In-Time compiler assembler, deployed in a single DLL that takes source code strings and returns executable

declareACTION: declareaprocedurewithitsprototype(maybeexternalordeclared

inadvance)EXAMPLE:

declarefun(floata,b,c,d)asfloat

declarefunctionfun(floata,b,c,d)asfloat

REMARKS: ThereisawiderangeofoptionsforDeclarestatements.Pleaselookattheexamplesandheaderfiles.

RELATED: !librarylibaliasdim

Page 203: Oxygen Basic Compiler - documentation.help · Oxygen Basic (o2H) is a Just-In-Time compiler assembler, deployed in a single DLL that takes source code strings and returns executable

#elseACTION: alternativeblockofcodetoincludeifpriorconditionsarenotmet.RELATED: #if#elseif#endif

Page 204: Oxygen Basic Compiler - documentation.help · Oxygen Basic (o2H) is a Just-In-Time compiler assembler, deployed in a single DLL that takes source code strings and returns executable

acosACTION: returnsangleinradiansgiventheratiox/radiusUSE: angle=acos(YRRatio)EXAMPLE:

a=acos(0.5)

RESULT:a=pi/3

RELATED: cosasinatnatan

Page 205: Oxygen Basic Compiler - documentation.help · Oxygen Basic (o2H) is a Just-In-Time compiler assembler, deployed in a single DLL that takes source code strings and returns executable

atnACTION: returnsangleinradiansgivenratioy/xUSE: angle=atn(YXRatio)EXAMPLE:

a=atn(1)*4

RESULT:a=pi

RELATED: atanasinacostan

Page 206: Oxygen Basic Compiler - documentation.help · Oxygen Basic (o2H) is a Just-In-Time compiler assembler, deployed in a single DLL that takes source code strings and returns executable

atanACTION: returnsangleinradiansgiventhevaluesofyandxUSE: angle=atan(y,x)EXAMPLE:

a=atan(0.5,sqr(0.75))

RESULT:a=pi/6

RELATED: atnasinacostan

Page 207: Oxygen Basic Compiler - documentation.help · Oxygen Basic (o2H) is a Just-In-Time compiler assembler, deployed in a single DLL that takes source code strings and returns executable

aliasREMARKS: iftheprocedurenameisanexactcasematchthenitisnot

necessarytospecifyanAlias.

RELATED: librarydeclareexternallibrarydeclareexternal

Page 208: Oxygen Basic Compiler - documentation.help · Oxygen Basic (o2H) is a Just-In-Time compiler assembler, deployed in a single DLL that takes source code strings and returns executable

convertACTION: explicitlyconvertthetypeofanexpression.USE: passvalues,intherequiredtype,toanunprototypedfunctionEXAMPLE:

floatf=2.5

sleep(convertint(f*1000))

RELATED: cast

Page 209: Oxygen Basic Compiler - documentation.help · Oxygen Basic (o2H) is a Just-In-Time compiler assembler, deployed in a single DLL that takes source code strings and returns executable

typeofACTION: returnnameofthevariabletypeUSE: name=typeofvariableEXAMPLE:

dimaslongv:s=typeofv

RESULT:s="long"

RELATED: typecodeofsizeofoffsetofspanofrecordof

Page 210: Oxygen Basic Compiler - documentation.help · Oxygen Basic (o2H) is a Just-In-Time compiler assembler, deployed in a single DLL that takes source code strings and returns executable

recordofACTION: returnrecordofcompound(UDT)variableUSE: obtaindatafordiagnosticsorreflectiveprogrammingEXAMPLE:

typevtlongv,doubled

dimasvtv:r=recordofv

RESULT:r="

v041A0,long

d441A0,double

"

REMARKS: use#recordoftodisplaytherecordduringcompilation.

RELATED: #recordofprototypeofsizeofoffsetofspanoftypeoftypecodeof#recordof

Page 211: Oxygen Basic Compiler - documentation.help · Oxygen Basic (o2H) is a Just-In-Time compiler assembler, deployed in a single DLL that takes source code strings and returns executable

offsetofACTION: returnoffsetofvariablefromindexregisterUSE: nbytes=offsetofvariableEXAMPLE:

n=offsetofa

RELATED: sizeofspanoftypeoftypecodeofrecordof

Page 212: Oxygen Basic Compiler - documentation.help · Oxygen Basic (o2H) is a Just-In-Time compiler assembler, deployed in a single DLL that takes source code strings and returns executable

spanofACTION: returnspanofarrayvariabledimensionUSE: nbytes=spanofvariabledimensionEXAMPLE:

dimaslongv(10):n=spanofv

RESULT:n=10

RELATED: sizeofoffsetoftypeoftypecodeofrecordof

Page 213: Oxygen Basic Compiler - documentation.help · Oxygen Basic (o2H) is a Just-In-Time compiler assembler, deployed in a single DLL that takes source code strings and returns executable

prototypeofACTION: returnprototype(s)offunctions,subsandhighlevelmacrosUSE: obtaindatafordiagnosticsorreflectiveprogrammingRELATED: recordofsizeofoffsetofspanoftypeoftypecoedof#recordof

Page 214: Oxygen Basic Compiler - documentation.help · Oxygen Basic (o2H) is a Just-In-Time compiler assembler, deployed in a single DLL that takes source code strings and returns executable

#recordofACTION: returninternalrecordofadeclaredentity.USE: tocheckstatusatcompiletime.EXAMPLE:

#recordofMyStructure

REMARKS: thiscommandwasintroducedtoaiddebuggingatcompiletimeareoftenhardtotrace.

RELATED: #blockdepth