Global #define constants and global variables ?

Discussion about the ZBasic language including the System Library. If you're not sure where to post your message, do it here. However, do not make test posts here; that's the purpose of the Sandbox.
Post Reply
spamiam
Posts: 739
Joined: 13 November 2005, 6:39 AM

Global #define constants and global variables ?

Post by spamiam »

Is there a way to have global #define constants and global Dim variables span the whole project. I tried using #include to add a file of #defined constants, but that did not work. the widest scope of variables I can get is just within the individule .BAS file, but not across all .BAS files.

Is there a solution? I realize that project scope variables are frowned upon stylistically, but there would only be a couple of them and it save use of getters and setters.

-Tony
dkinzer
Site Admin
Posts: 3120
Joined: 03 September 2005, 13:53 PM
Location: Portland, OR

Re: Global #define constants and global variables ?

Post by dkinzer »

spamiam wrote:Is there a way to have global #define constants and global Dim variables span the whole project.
For a #define constant to be available across all modules, it must be defined on the command line. This can most easily be done via the project file.

Code: Select all

-Dfoo=bar
See section 10.2 of the ZBasic Language Reference for more details.

As for variables, use Public instead of Dim to make them globally available.
- Don Kinzer
Post Reply