Order of creating Types

Previous topic - Next topic

Leginus

Not sure if this is a bug, or just the way that things are in the order of the coding universe :)

I the following two types set up something like this.

Code (glbasic) Select

TYPE Carts
    x
   y

   FUNCTION Animate
      Building[0].Working = 1
   ENDFUNCTION

ENDTYPE
GLOBAL Cart[] AS Carts

//------------------------------------------------

TYPE Building
   Working
   x
   y
ENDTYPE
GLOBAL Buildings[] AS Building
DIM Buildings[1]


This isnt the exact code, but a scenario to show you as the actual code is huge.
Both these type are setup in a separate code sheet to the main program, but called obviously as it runs.

The problem is (or maybe it isnt) is that I cannot compile this program without moving the Buildings type above the Cart type on the code screen, otherwise the compiler states
Code (glbasic) Select
TYPE  is not declared.

I could understand this if the program was running, but should the compiler not check all the functions before it starts assesing whether or not something exists, or am I barking up the wrong tree  O_O






MrTAToad

Its not a bug - there is no forward looking for matching types.  You have to define the TYPE in the order they are to be used (if they reference other types)

Leginus

OK thanks for reply.  I suspected this maybe the case.  :-[

Kitty Hello

hm, that should work....