Having trouble compiling my program. I am using types instead of arrays now. I cannot see where I am going wrong and need a fresh pair of eyes, please.
`Main Source File
// variables
global sw as word = 1024
global sh as word = 768
global bpp as byte = 32
global dmodeavail as boolean = 0
global wintitle as string = "Capital Ship Simulator 0.01a"
global maxobjs as integer = 100
global dim obj(maxobjs) as dl_objtype
set window title wintitle
dmodeavail = check display mode( sw, sh, bpp )
// display
if dmodeavail > 0
set display mode sw, sh, bpp
else
msgbox "current display mode not supported!", 0, 0
exit
endif
set window position 150, 50
// main program
do
for x = 1 to maxobjs
// update position and angle data for objects
if object exist( x ) > 0
obj.xp( x ) = object position x( x )
obj.yp( x ) = object position y( x )
obj.zp( x ) = object position z( x )
obj.xa( x ) = object angle x( x )
obj.ya( x ) = object angle y( x )
obj.za( x ) = object angle z( x )
endif
next x
sync
loop
// types /////////////////////////////////////////////////////////////////////////////
// type: dl_objtype
// n: object number
// p: model path
// xp, yp, zp: object position
// xa, ya, za: object angle
type dl_objtype
n as integer
p as string
xp as float
yp as float
zp as float
xa as float
ya as float
za as float
endtype
// functions /////////////////////////////////////////////////////////////////////////
//function: dl_loadobject
// path$: model file path
// objx#, objy#, objz#: object position
// returns: object number
function dl_loadobject( path$, objx#, objy#, objz# )
local object
for x = 1 to maxobjs
// find free object number
if object exist( x ) = 0
obj.n( x ) = x
object = x
load object path$, obj.n( x )
position object obj.n( x ), objx#, objy#, objz#
exitfunction object
endif
next x
endfunction 0
The error I keep getting from BlueIDE is:
Error at line 34:
obj.xp( x ) = object position x( x )
PARSER ERROR
------------
Variable 'obj' does not exist at line 34.
PROGRAM TRACE
-------------
obj.xp( x ) , object position x( x )
obj.yp( x ) = object po
ERROR TRACE
-----------
Failed to 'Calculate DataOffsetAndTypeFromFieldString'
Failed to 'DoExpressionList::DoExpressionListString'
Failed to 'DoInstruction::Do ExpressionList'
Failed to 'DoAssignment::DoInstruction'
Failed to 'DoStatement(TokenID)'
Failed to 'pJumpBlockA->DoBlock'
Failed to 'DoStatement(TokenID)'
Failed to 'pLoopBlock->DoBlock()'
Failed to 'DoStatement(TokenID)'
Failed to 'pLoopBlock->DoBlock()'
Failed to 'DoStatement(TokenID)'
Failed to 'DoBlock(0)'
Failed to 'MakeStatements'
Failed to Parse Program (MakeDBM->MakeProgram)'