Post Reply 
Confused about LOCAL....
11-17-2017, 04:04 PM
Post: #10
RE: Confused about LOCAL....
(11-16-2017 06:04 AM)webmasterpdx Wrote:  Cyrille, my understanding (and this is what the documentation says) is that a program global is EXPORT A; outside of a function.
So, you are saying that LOCAL A; outside of a function is, in fact, treated as a global, but isn't accessible by anything other than functions defined inside the same program file.
Thus, LOCAL A; outside a function, cannot coexist with an existing global, either inside another program file or a true global/system variable. This is why LOCAL A; gives a compile error.
Is my interpretation here correct?
Thx
-Donald

To answer your question directly: YES. In the specific case when you try to declare a LOCAL variable OUTSIDE of any function AND using an existing system variable name, you will get a compile error.

Now, if you had a different program file (say, PROG1) that declared EXPORT MYVAR1; and within yet another program file (named PROG2) you declared EXPORT MYVAR1, you will NOT get a compile error. The program will (I have not tested this) use the correct MYVAR1 since at compile time it creates reference links to variables and functions. However, if you try to access MYVAR1 from outside the program (i.e. via command line to perhaps modify the content of MYVAR1), then the MYVAR1 that was last compiled is what gets referenced. In order to reference the correct MYVAR1, you need to qualify them with the program file name: PROG1.MYVAR1 or PROG2.MYVAR2

The ambiguous behavior only occurs when you use the (ambiguous) shorthand names to reference the variables.

Graph 3D | QPI | SolveSys
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
Confused about LOCAL.... - webmasterpdx - 11-15-2017, 06:19 AM
RE: Confused about LOCAL.... - Dirk.nl - 11-15-2017, 12:18 PM
RE: Confused about LOCAL.... - Carlos295pz - 11-16-2017, 06:43 AM
RE: Confused about LOCAL.... - Carlos295pz - 11-16-2017, 06:55 AM
RE: Confused about LOCAL.... - Tim Wessman - 11-16-2017, 05:13 PM
RE: Confused about LOCAL.... - Han - 11-17-2017 04:04 PM



User(s) browsing this thread: 1 Guest(s)