GLBasic forum

Main forum => Bug Reports => Topic started by: Leginus on 2011-Feb-11

Title: Order of creating Types
Post by: Leginus on 2011-Feb-11
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





Title: Re: Order of creating Types
Post by: MrTAToad on 2011-Feb-11
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)
Title: Re: Order of creating Types
Post by: Leginus on 2011-Feb-11
OK thanks for reply.  I suspected this maybe the case.  :-[
Title: Re: Order of creating Types
Post by: Kitty Hello on 2011-Feb-12
hm, that should work....