Post Reply 
Prime app variables
12-15-2013, 04:37 AM
Post: #12
RE: Prime app variables
(12-15-2013 04:02 AM)Bob Frazee Wrote:  Han;
Thanks for being patient with me. My definition of global, is global to the WindChill program. The behavior of the variables would be as stated in post #7. Variables DegF and Mph are the two inputs that all the other values are calculated from. Those are the 2 values I would like to keep, and possibly a List file would be the best way to accomplish that. As an example, variable DegF is created in the InputScreen subroutine. It then needs to be passed to WindChillEqn, FrostbiteEqn,IntroScreen,and OutputScreen via the WindChill program, so I added DegF; to the WindChill program.

I had not declared my subroutines, as you show in post #8, so I tried that. I am still unable to get values passed. One thing that is possibly not clear is that the above subroutines are not part of the WindChill program file. They are 5 individual files in calculator memory. Possibly that makes a difference in the passing of variable values.
Thanks
rcf

Yeah, keeping them in one source file does make a difference, especially in the case of hidden global variables and the scope of EXPORT (for both variables and subroutines). Declaring subroutines is only relevant for subroutines that appear in the same source file. I believe those are only visible to programs declared within the same source file. So if you are calling programs from a different source file, then no declarations are needed. However, those other programs must be EXPORT'ed. That said, it is still possible to pass parameters to programs that are separated into many different source files. However, there are really only two ways I can think of:

1. EXPORT'ed global variables
2. Passing parameters via local variables in the receiving program

An example of 2, using separate source files:

In order to use separate source files, you would likely need to do something like:

File 1
Code:

globalvar1, globalvar2; // hidden global variables only within the scope of File 1

EXPORT MainProg()
BEGIN
  // keep globalvar1 as a list if you want simple code
  globalvar1:=Prog1(); // no need to declare at top
  globalvar2:=Prog2(globalvar1); // pass parameters to Prog2  
END;

File 2
Code:

// MUST BE EXPORTED!! otherwise it cannot be called by neither user nor other programs
EXPORT Prog1() 
BEGIN
  LOCAL a, b, c;
  // code that gets values for a, b, and c
  RETURN({a,b,c}); // use a list to return multiple values
END;

File 3
Code:

// MUST BE EXPORTED!! otherwise it cannot be called by neither user nor other 
EXPORT Prog2(list) // list becomes a local variable; auto-declared here
BEGIN
  // list(1) is the 'a' value passed from Prog1
  // list(2) is the 'b' value passed from Prog1
  // list(3) is the 'c' value passed from Prog1
  RETURN( /* insert what you want to be saved as globalvar2 */ );
END;

The variables globalvar1 and globalvar2 will retain their values the next time you run MainProg(). Any other subroutine coded inside File 1 will be able to use these two global variables. However, Prog1() and Prog2() cannot use globalvar1 and globalvar2 as they are not in the same scope (source file, if you will).

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: 1 Guest(s)