Project Files & 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
everest
Posts: 96
Joined: 31 May 2010, 9:01 AM

Project Files & Variables

Post by everest »

Hey Don,

I've noticed that global variables from one file to the next don't seem to carry over in a project. Is that an inherent limitation or am I just missing something (as usual!)?

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

Re: Project Files & Variables

Post by dkinzer »

everest wrote:I've noticed that global variables from one file to the next don't seem to carry over in a project.
They do if you define them in a particular way. A variable defined at the module level (outside of any procedure) can be truly global (i.e. visible to other modules) or it may be private to the module (i.e. only visible to procedures in that module). If you define a variable at the module level using the Dim keyword it is private to the module. If you want it to be visible to procedures in other modules, you must define it using Public instead of Dim.

The distinctions between Public, Private and Dim are explained in the ZBasic Language Reference Manual in the section entitled Defining Variables.
- Don Kinzer
everest
Posts: 96
Joined: 31 May 2010, 9:01 AM

Post by everest »

Ah ha! I figured it was something I was missing. Naturally related to a "Dim" statement. . .somewhat insulting really. . . . :roll:

-Jeff
Post Reply