All Pb to O2 conversions
this is the list of commands/ guide lines which i would use to convert my programs from PB to O2
hope that anyone else can share their thoughts in converting to O2, you can amend this list
conversion from PB to O2
conversion is indicated by -->
1. Find and strip off all $ in these functions
MID$() --> MID()
RIGHT$() --> RIGHT()
LEFT$() --> LEFT()
CHR$() --> CHR()
SPACE$() --> SPACE()
STR$() --> STR()
STRING$() --> STRING()
TRIM$ --> you need to define it as
def trim ltrim(rtrim(%1))
AND --> &&
2^7 --> use power function --> pow(2,7)
2. There is no RANDOMIZE and RND() functions
so need to add in
Use Chaos
and use irnd(3, 100 )
irnd(3, 100 ) means getting a random integer between 3 and 100
3. Break up complex multiple functions line into smaller bits for eg
insXor = VAL("&H" + MID(value1, loopit, 1)) XOR VAL("&H" + MID(value2, loopit, 1))
use the component step by step codes instead, otherwise the O2 compiler cannot compile
and may returns error
i1="&H" + MID(value1, loopit, 1)
i2="&H" + MID(value2, loopit, 1)
insXor=i1 xor i2
4. ' Note that in O2 we can assign strings to an integer number directly
' the compiler is VERY smart and adaptive
tempnum = "&H" + MID(tempstr, loopit, 1)
int a ,b
a = 1
b = "2"
' this results in 3
PRINT a + b
5. Try not to use VAL function as it will convert the number to a float and gets error later on
tempnum = VAL("&H" +"5E65A486")
just use directly
tempnum ="&H" +"5E65A486"
6. In 64bit, int no longer matches sys may need to convert int to O2 sys also applies to the following
INTEGER , LONG , DWORD --> sys
you need to test these functions out after conversion and most of the time it works for me
7. BYTE --> int