Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / Can the compiler warn you about undeclared vars?

Author
Message
Railgun
18
Years of Service
User Offline
Joined: 2nd Sep 2006
Location: Galveston Bay
Posted: 8th Sep 2006 01:59
Sorry to keep bugging you guys with these trivial questions but last time I programmed in BASIC was when I was a kid.

Anyway, so the thing that keeps tripping me up is I'll declare a var like



and of course, my function will do something weird because I used the wrong var name.

So is there any switch you can set or keyword you can use like in VB so the compiler will give you an error/warning for using a var that you didn't declare?
CattleRustler
Retired Moderator
21
Years of Service
User Offline
Joined: 8th Aug 2003
Location: case modding at overclock.net
Posted: 8th Sep 2006 03:06
put them inside a user defined type

type MyVars
iX as Integer
End Type

V as MyVars

V.ix=10


The compiler will stop on undeclared udt's

BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 8th Sep 2006 12:14
Doing what CR says is a good way to program anyway. You can create a Type for general globals, a Type for display-related variables, and so on. It makes your code far more understandable when you see:

Display.depth = 32

It's instantly recognisable as a feature of the screen, not a bitmap, image or something else more obscure.



Login to post a reply

Server time is: 2024-11-27 07:26:47
Your offset time is: 2024-11-27 07:26:47