Post Reply 
Prime app variables
12-13-2013, 05:42 PM
Post: #4
RE: Prime app variables
(12-13-2013 05:27 PM)Jonathan Cameron Wrote:  Thanks Han,

Regarding your point 2: Do you mean that I declare the non-exported variables with a LOCAL statement within the main BEGIN-END block for the App or something else?

-Jonatha

No, local variables are entirely different as their scope is limited to the (sub)program that delcares them. When you use EXPORT, you are essentially creating a global name (either a variable or a program) that becomes visible to the user. They can interact with it. These global variables are likewise accessible by any other program (be it within the app, or even from outside the app provided the calling program uses the proper app prefix). If you want to create a variable that is likewise accessible to programs, but NOT to users, then you simply remove the export command. So for example, the source to your app may have:

Code:

EXPORT myvar1; // global var which users can alter; other programs can use
myvar2; // global var which other programs can access, but is hidden from users

EXPORT Program1(a,b,c) // this program is visible to users and other programs
BEGIN
  myvar1:=a+b+c;
  myvar2:=a^2+b^2+c^2;
END;

Program2(x,y) // this program can be used by Program1 but not by users
BEGIN
  LOCAL r, s, t; // these variables can only be used within Program2
  myvar1:=a-b*c;
  myvar2:=r-t+x*y;
END;

So in the snippet above, the local variables are a, b, c, x, y, r, s, and t and can only be accessed by their respective programs. The global variables myvar1 and myvar2 can be used by any program; however only myvar1 can be altered by users manually. For example, a user could simply type: myvar1:=9; to override the current value, whereas they cannot alter myvar2 whatsoever.

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


Messages In This Thread
Prime app variables - Jonathan Cameron - 12-13-2013, 03:33 PM
RE: Prime app variables - Han - 12-13-2013, 04:02 PM
RE: Prime app variables - Jonathan Cameron - 12-13-2013, 05:27 PM
RE: Prime app variables - Han - 12-13-2013 05:42 PM
RE: Prime app variables - Jonathan Cameron - 12-13-2013, 06:17 PM
RE: Prime app variables - Han - 12-13-2013, 07:28 PM
RE: Prime app variables - Bob Frazee - 12-13-2013, 09:44 PM
RE: Prime app variables - Han - 12-14-2013, 02:36 AM
RE: Prime app variables - Bob Frazee - 12-14-2013, 03:19 PM
RE: Prime app variables - Han - 12-14-2013, 09:19 PM
RE: Prime app variables - Bob Frazee - 12-15-2013, 04:02 AM
RE: Prime app variables - Han - 12-15-2013, 04:37 AM
RE: Prime app variables - Bob Frazee - 12-16-2013, 12:40 AM



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