Post Reply 
Global Variables?
04-03-2017, 10:11 AM (This post was last modified: 04-03-2017 10:12 AM by toml_12953.)
Post: #5
RE: Global Variables?
(04-03-2017 03:02 AM)Han Wrote:  
(04-03-2017 02:59 AM)toml_12953 Wrote:  Thanks, Joe. I knew about that but also know you can create local variables as any type you want. I was hoping there was some way to create a variable local to the program but global to all the subprograms in the program.

Tom L

Just declare them at the top of your source file.

Code:

// these may be accessed by any program created after the declaration of these variables
myvar1:={1,2,3}; 
myvar2:="Hello world";
myvar3:=1.2345;

EXPORT MYPROG1()
BEGIN
  PRINT(myvar1);
END;

EXPORT MYPROG2()
BEGIN
  myvar3:=myvar3 + 2;
  PRINT(myvar3);
END;

The point of my post was that that doesn't work with uppercase variables. Try this:

Code:
N:=100;
R:=MAKEMAT(0,100);
myvar1:={1,2,3}; 
myvar2:="Hello world";
myvar3:=1.2345;

EXPORT MYPROG1()
BEGIN
  PRINT(myvar1);
END;

EXPORT MYPROG2()
BEGIN
  myvar3:=myvar3 + 2;
  PRINT(myvar3);
END;

Tom L
Cui bono?
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
Global Variables? - toml_12953 - 04-03-2017, 12:40 AM
RE: Global Variables? - Joe Horn - 04-03-2017, 02:10 AM
RE: Global Variables? - toml_12953 - 04-03-2017, 02:59 AM
RE: Global Variables? - Han - 04-03-2017, 03:02 AM
RE: Global Variables? - toml_12953 - 04-03-2017 10:11 AM
RE: Global Variables? - jte - 08-15-2021, 12:27 AM
RE: Global Variables? - Joe Horn - 08-15-2021, 12:49 AM
RE: Global Variables? - jte - 08-15-2021, 01:22 AM
RE: Global Variables? - Joe Horn - 08-15-2021, 03:57 AM
RE: Global Variables? - DrD - 04-03-2017, 10:25 AM
RE: Global Variables? - toml_12953 - 04-03-2017, 04:39 PM
RE: Global Variables? - cahlucas - 08-18-2021, 04:37 AM
RE: Global Variables? - toml_12953 - 08-18-2021, 09:55 AM
RE: Global Variables? - cahlucas - 08-19-2021, 04:50 AM
RE: Global Variables? - toml_12953 - 08-19-2021, 08:57 AM
RE: Global Variables? - Stevetuc - 08-19-2021, 03:38 PM
RE: Global Variables? - jte - 01-20-2023, 02:46 AM
RE: Global Variables? - cahlucas - 08-20-2021, 04:04 PM
RE: Global Variables? - toml_12953 - 08-20-2021, 06:26 PM
RE: Global Variables? - compsystems - 04-03-2017, 01:18 PM



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