GLBasic Libraries...

Previous topic - Next topic

bigsofty

Im having a lot of trouble keeping my code in separate modules (files) together with there variables.

My library code is almost always the same.

Types
Global Variables
SubRoutines

I keep getting "TYPE  is not declared", Ive tried putting the variables in a function and calling it from the main program but Im still getting this error.

I mainly get this error if I try and read (from the main program)  a globally declared variable from a library

Any ideas?
Cheers,

Ian.

"It is practically impossible to teach good programming style to students that have had prior exposure to BASIC.  As potential programmers, they are mentally mutilated beyond hope of regeneration."
(E. W. Dijkstra)

Kitty Hello

Any code? Without code it's always hard to tell. Make small programs and post them or upload them zipped. Might be a bug, might be a typo, might be some misunderstanding. I suppose it's a bug, though. ;)

bigsofty

OK, Ill try and cut the code down and still show the error. As Arnold would say "I'll be Back!" :P
Cheers,

Ian.

"It is practically impossible to teach good programming style to students that have had prior exposure to BASIC.  As potential programmers, they are mentally mutilated beyond hope of regeneration."
(E. W. Dijkstra)

Kitty Hello

Gif meh zeh guhn!

bigsofty

Code (glbasic) Select
*** Configuration: WIN32 ***
precompiling:
GPC - GLBasic Precompiler V.2007.095 - 3D, NET
"test.gbas"(12) error : wrong argument type : X_CAMERA, arg no: 1
TYPE  is not declared
Main program...

Code (glbasic) Select
// --------------------------------- //
// Project: TEST.GBAS
// Start: Saturday, April 14, 2007
// IDE Version: 4.154


foo()


WHILE TRUE
     X_MAKE3D 1,5500,45
X_CAMERA cameraPosition.x, cameraPosition.y, cameraPosition.z, cameraTarget.x, cameraTarget.y, cameraTarget.z
     SHOWSCREEN
WEND
Dummy library...

Code (glbasic) Select
// --------------------------------- //
// Project: CAMERA_LIB.GBAS
// Start: Saturday, April 14, 2007
// IDE Version: 4.154


// Types
TYPE Tvector
    x
    y
    z
    magnitude
ENDTYPE


// Globals
FUNCTION foo:
GLOBAL PI = 3.1415926535
  GLOBAL cameraPosition AS Tvector
  GLOBAL cameraTarget AS Tvector
  GLOBAL cameraUpVector AS Tvector
  GLOBAL radius = 1
  GLOBAL moveDist = 1
  GLOBAL hRadians
GLOBAL vRadians
ENDFUNCTION

//Functions
FUNCTION SetCamera: cPosition AS Tvector, h ,v
    hRadians = h
    vRadians = v
ENDFUNCTION
The above program does nothing but illustrate how I can not modularise types, globals and functions in the one file. I need this to post some stuff on the forums or use code between programs.
Cheers,

Ian.

"It is practically impossible to teach good programming style to students that have had prior exposure to BASIC.  As potential programmers, they are mentally mutilated beyond hope of regeneration."
(E. W. Dijkstra)

bigsofty

Quote from: GernotFrischGif meh zeh guhn!
LOL, I went to babelfish (As I do quite a bit) to translate this from German to English... then I realised what it said... haha... doh! :D
Cheers,

Ian.

"It is practically impossible to teach good programming style to students that have had prior exposure to BASIC.  As potential programmers, they are mentally mutilated beyond hope of regeneration."
(E. W. Dijkstra)

Kitty Hello

Hokay! If you use a global, make sure you tell the compiler about it before you use it. Like
GLOBAL cameraPosition AS TVector
in main game function. You declare it as GLOBAL later, so GLBasic should be clever enough to realize that. I'll dig into it for the next update. Maybe I can fix it.

bigsofty

Yep, I've been doing that... thanks any ways Gernot, I hope you have luck with the update.
Cheers,

Ian.

"It is practically impossible to teach good programming style to students that have had prior exposure to BASIC.  As potential programmers, they are mentally mutilated beyond hope of regeneration."
(E. W. Dijkstra)