PlayBASIC V1.64 K BETA #4 (Retail Compiler Only Beta) - (Avail for Registered Users ONLY) PB V1.64k4 is the latest beta of PBV1.64 retail update. This beta brings a few new compiler level changes to PB, namely math short support and Byte & Word field support in User Defined Types.
Math Short cuts are another idea borrowed from C. The syntax is basically the same, expect PB only supports these operations in Assignments, while in C you can apply them anywhere, which is handy in C, not so much in BASIC.
What are they ? - Well they're simply a way of short cutting math operations being performed upon the same variable or array.
For example, in older versions of PB, if you have a variable SCORE and wish to add 100 to it, they you'd either type Score=Score + 100 or use the INC operator. Eg INC score,100 (Note: Only available in older editions of PB V1.64)
Now in
V1.64K we have the following short cut operators.
++ ; Increase by one. This is the eqivilent of INC operator. Except you can use these on arrays/ type fields
-- ; decrease by one. This are the eqivilent of DEC operator. Except you can use these on arrays/ type fields
+= ; Add right value to left. Eg Score += 100 , is the same as Score = Score +100
-= ; Subtract right value from left. Eg Score -= 100 , is the same as Score = Score -100
*= ; Multiply right value by left. Eg Score *= 100 , is the same as Score = Score *100
/= ; Divide right value by left. Eg Score /= 100 , is the same as Score = Score /100
So really these additions just allow us to shorten some long expressions. These operators can be used on most data types and structures within PB. Including Integers, Floats, Strings, Arrays, Pointer writes (limited support) and even User Defined Users. However Array Field elements in User defined types are not currently supported.
Dim Table(2000)
Table(110)+=1000
Table(110)-=2222
print Table(110)
Dim Table#(1000)
Table#(10)=1000
Table#(10)/=50
print Table#(10)
Dim Table$(200)
Table$(10)="Yeah"
Table$(10)+="Dude"
print Table$(10)
a$="Cool"
print a$
c$="DUDEDDD"
b$="YESAH"
A$=C$+b$
print a$
a$++
print a$
Type Test
Aaa
X
Y#
z$
EndType
Dim Dude as test
Dude.x +=100
Dude.x +=100
Dude.x +=100
Print Dude.x
Dude.y +=200
Dude.y +=200
Print Dude.y
Dude.z +="aaa"
Dude.z +="bbb"
Print Dude.z
Dim Qrr(10,5) as test
print "Typed Array"
Qrr(10,5).x =45
Qrr(10,5).x +=100
Qrr(10,5).x +=100
Qrr(10,5).x +=100
Print Qrr(10,5).x
Dim You2 as integer pointer
Dim You as integer pointer
Bank=NewBank(1000)
addr=GetBankPtr(Bank)
You= addr
*You = 45
*You += 100
*You *=2
*You /=10
print *You
Dim Me as test pointer
Me = new test
me.x =13
print me.x
me.x *=4
print me.x
me.x /=13
print me.x
print "Y test"
me.y +=22
print me.y
me.y *=4
print me.y
me.y /=13
print me.y
me.z +="HellO"
me.z +="HellO"
me.z +="HellO"
print me.z
Sync
waitkey
Byte & Word Fields As of PB1.64k, PB now supports BYTE (8 bit unsigned) and WORD (16bit unsigned) fields within User defined type structures. This address a bit of gotcha when trying to work with some external functions (ie windows, other 3rd party dll's mainly).. But you can use this stuff in your programs like so.
// Create a structure so we can access the fields of ARGB colour
// directly from memory (via pointer). Notice the order, INTEL
// sludge boxes use LITTLE ENDIAN, so longs are stored in memory in reverse order
Type Colour
B as byte
G as byte
R as byte
A as byte
EndType
// allocate a bank the size of the Colour structure (4 bytes in other words)
Bank=NewBank(sizeOf(Color))
// me a user defined type pointer, so we can query memory.
Dim me as Colour Pointer
// set the ME to point at our Bank
Me = GetBankPtr(Bank)
// Poke a colour into the bank
PokeBankInt Bank,0,Argb(50,100,200,250)
// use the Typed Pointer to query the colour that we stored in the bank
print Me.A
print Me.R
print Me.G
print Me.B
Sync
waitkey
Download
Get newer version bellow.
WIP Thread
Follow the WIP beta gallery thread in the show case