Main Menu

Syntax Error? or just not possible?

Started by Draco9898, February 12, 2005, 09:55:15 PM

Previous topic - Next topic

Draco9898

Hmmm I'm trying to call a function which returns several values back into a typed array, but this doesnt seem to work?

For Example:

PlayBASIC Code: [Select]
Type tCamera
Index,X#,Y#,OldX#,OldY#
EndType
Dim Camera As TCamera
Camera.Index=GetFreeCamera()
CreateCamera Camera.Index

Type TPlayer
X#,Y#,Z#,XVelo#,YVelo#,XAccel#,YAccel#
EndType
Dim Player As TPlayer

; ---------------------------------------------------------------------
`MAIN LOOP>>>>>>>>>>>>>>>>
; ---------------------------------------------------------------------
Do
ClsScene
CaptureToScene

`Slap physics values for player into function and Get Physics Values Back
Player.X#, Player.Y#, Player.Z# = MoreReturnValues()

Box Player.X#-16,Player.Y#-16,Player.X#+16,Player.Y#+16,1

DrawCamera Camera.Index
Sync
Loop

; ---------------------------------------------------------------------
`Functions>>>>>>>>>>>>>>>>
; ---------------------------------------------------------------------
; A Psub that returns three values
Psub MoreReturnValues()
Life = 42
Life2 = 64
EndPsub Life, Life2, 4.321




will not work, it just says "expecting equals" ?
DualCore Intel Core 2 processor @ 2.3 ghz, Geforce 8600 GT (latest forceware drivers), 2 gigs of ram, WIN XP home edition sp2, FireFox 2.

"You'll no doubt be horrified to discover that PlayBasic is a Programming Language." -Kevin

kevin


kevin

#2
You can achieve the same effect by simply passing the Type into the fucntion.  The passed type has strictly match though, or be the child a parent type.  but it's less typing..  :)


PlayBASIC Code: [Select]
 Dim Player1 as tplayer
Dim Player2 as tplayer

; init player1
Setplayer(PLayer1.tplayer,100,200,5000)
Setplayer(PLayer2.tplayer,4005200,5000)

etc

Psub SetPLayer(ThisPlayer.tplayer,x#,y#,score)
ThisPlayer.x= x#
ThisPlayer.y= y#
ThisPlayer.Score= Score
EndPsub
endif