(http://underwaredesign.com/PlayBasicSig.png) (http://playbasic.com/)
PlayBasic 1.50c BETA (Retail Compiler Only Beta) - (Registered) (October 07, 2006)
PlayBASIC 1.50c is the current WIP of PB. Latest additions are virtually all TYPE and pointer related. You can now make complex assignments between TYPEd structures.
Note: While i've tested this with a lot of demo code, you should be aware that I've re-written large parts of the Type system, so I wouldn't be too surprised if it hangs on something type related. If you find something, REPORT IT ! Don't ASSUME we've noticed it.
Download For Latest ->PlayBasic Retail Upgrade Announcements (http://www.underwaredesign.com/forums/index.php?topic=1774.30)
History
Version Date Dizzy
-------- ---- -----
1.50c 5/8th,Oct,2006
* Fixes
- Trapped possible double declare of input/output pointer params
in function prototypes
- Fixed Input/output Type Matching of passed USD Pointer params
* Changes
- Rebuilt the User Defined Type structures 'again'.
1.50b 30th-3rd,Oct,2006
* Adding
- Started adding support for complex Type Assignments
- Writing Zero/NULL to a UDT pointer will null(delete) the UDT fields
*Changes
- GetTokens returns UDT indexes now rather than offset
- nested types import the field name as a UDT field.
*New Constants
- NULL
(http://underwaredesign.com/PlayBasicSig.png) (http://playbasic.com/)
PlayBasic V1.51 _Retail Patch_ is Now Available (October 08, 2006)
This release patches the existing PB1.089c / PB1.33 & PB1.44 retail releases, plus all of the subsequent retail patches (v1.11 up to 1.50) to the current retail release version of PBV1.51.
Release PB1.51 includes the latest EDITOR / HELP Files / Compiler and Release + Debug Runtimes. Most recent major additions elate to TYPES and User Defined Type Pointer support. Check the examples bellow to explore these new expansions.
For more information about PlayBASIC, please visit the PlayBASIC home page, download the demo and dive right on in..
Url: www.PlayBasic.com (http://www.playbasic.com)
History Changes since PB1.50
Version Date Dizzy
-------- ---- -----
1.51 8th,Oct,2006
* Fixes
- Type Inherits were broken
1.50c 5/8th,Oct,2006
* Fixes
- Trapped possible double declare of input/output pointer params
in functions prototypes
- Fixed Input/output passed #2 USD Pointer data type matching
- Updating Types to new system.
* Changes
- Rebuilt the User Defined Type structures 'again'.
1.50b 30th-3rd,Oct,2006
* Adding
- Started adding support for complex Type Assignments
- Writing ZEro to a UDT pointer will null(delete) the UDT fields
*Changes
- gettokens returns UDT indexes now rather than
offset
- nested types import the field name as a UDT field.
*New Cosntants
- NULL
Examples User Defined Types
Type rect
x1,y1,x2,y2
Endtype
Type Pos
x,y,z
Table(100)
name as string
R as rect
EndType
Dim Me as pos
Dim You as pos
; fill me with stuff
me.x=5
me.y=6
me.z=7
me.r.x1=10000
me.r.y1=10001
me.r.x2=10002
me.r.y2=10003
me.name$="I'm a String String String"
For x=10 to 20
Me.table(x)=100+x
next
; copy the ME type variable to YOU
You.pos=me.pos
; null the ME type Variable
me.pos=0
; show them
ShowMe(me.pos)
ShowMe(You.pos)
Sync
WaitKey
waitnokey
cls 0
; copy YOU back to me
me.pos=You.pos
; free the YOU Typed Variable
undim You.pos
; show them
ShowMe(me.pos)
ShowMe(You.pos)
Sync
WaitKey
waitnokey
Function ShowMe(zz.pos)
if GetArrayStatus(zz.pos)
print "================================"
print zz.x
print zz.y
print zz.z
print zz.name$
print "rect"
print zz.r.x1
print zz.r.y1
print zz.r.x2
print zz.r.y2
For lp=10 to 20
Print zz.table(lp)
Next
else
Print "Doesn't exist"
endif
EndfUnction
Assignments between typed Variables and Typed Array elements
Type rect
x1,y1,x2,y2
Endtype
Type Pos
x,y,z
Table(100)
name as string
R as rect
EndType
Dim Me as pos
Dim You as pos
Dim Objs(10) as pos
a=45
objs(1).y=a
objs(1).z=a*2
; fill me with stuff
me.x=5
me.y=6
me.z=7
me.r.x1=10000
me.r.y1=10001
me.r.x2=10002
me.r.y2=10003
me.name$="I'm a String String String"
For x=10 to 20
Me.table(x)=100+x
objs(1).table(x)=200+x
next
; copy the ME type variable to YOU
You.pos=objs(1).pos
objs(2).pos=objs(1).pos
me.pos=objs(2).pos
;me.pos
; null the ME type Variable
; me.pos=Null
; show them
ShowMe(me.pos)
ShowMe(You.pos)
/*
Sync
WaitKey
waitnokey
cls 0
; copy YOU back to me
me.pos=You.pos
; free the YOU Typed Variable
undim You.pos
; show them
ShowMe(me.pos)
ShowMe(You.pos)
*/
Sync
WaitKey
waitnokey
Function ShowMe(zz.pos)
if GetArrayStatus(zz.pos)
print "================================"
print zz.x
print zz.y
print zz.z
print zz.name$
print "rect"
print zz.r.x1
print zz.r.y1
print zz.r.x2
print zz.r.y2
For lp=10 to 20
Print zz.table(lp)
Next
else
Print "Doesn't exist"
endif
EndfUnction
User Defined Type Pointers
Type Pos
x,y,z
fx#,fy#,fz#
Stuff(100)
StuffFloat#(100)
StuffString$(100)
name$
EndType
Type Rect
x1,y1,x2,y2
EndType
Type Obj
p as pos
R as Rect
EndType
Dim Me as Obj Pointer
Dim You as Pos Pointer
; Alloc a TYPED Bank, this returns the address of this bank, NOT the BANK index
me=NewTypedBank(Obj)
; write data into it
me.p.x=45
me.p.y=66
me.p.z=77
me.p.fx#=12.345
me.p.fy#=22.345
me.p.fz#=32.345
me.p.name$="yeah yeah"
me.r.x1=400
me.r.y1=401
me.r.x2=402
me.r.y2=403
You=NewTypedBank(pos)
you.x =111111
You.y =22222
You.z =33333
You.name$="Kev"
Show(me)
Show(you)
Me.p =you
Show(me)
Show(you)
print "hey you nulled my .POS field"
me.p =0
Show(me)
print "hey you nulled my .Rect field"
me.r =0
Show(me)
; Print the Address of this pointer
print int(me)
; null out the type and Dealloc the memory (the bank in this case)
free me
; Print the Address of this pointer
print int(me)
sync
waitkey
end
Function Show(p2 as obj pointer)
print "================================="
print "pos fields"
Print str$(p2.p.x)+" - "+str$(p2.p.y)+" - "+str$(p2.p.z)
Print str$(p2.p.fx)+" - "+str$(p2.p.fy)+" - "+str$(p2.p.fz)
Print "name field:"+p2.p.name
print "rect fields"+str$(p2.r.x1)+" - "+str$(p2.r.y1)+" - "+str$(p2.r.x2)+" - "+str$(p2.r.y2)
EndFunction
Special Case Issue with PB1.51 detected
Post release a rather odd issue has been discovered with Passing typed Variables/Arrays and performing complex type assignments in PBV1.51.
For the bug to surface your code has to include this combination (includes type array passes into functions and has Typed Variable assignments). While this has now been hunted down and rectified with PB1.52, it might be a few days before a Patch can be released.