HP Forums
global variables HP-PPL - Printable Version

+- HP Forums (https://www.hpmuseum.org/forum)
+-- Forum: HP Calculators (and very old HP Computers) (/forum-3.html)
+--- Forum: HP Prime (/forum-5.html)
+--- Thread: global variables HP-PPL (/thread-7823.html)



global variables HP-PPL - compsystems - 02-24-2017 08:04 PM

Hello if you define global variables without export, they are not displayed in the menu VAR or MEM, but if they exist, you can check it by executing more than once the next program

PHP Code:
x:=0;
y:=0;
EXPORT inputv0()
BEGIN
 
//x:=5;
 
print();
 print(
"text1"); wait;
 
input);
 print(
"text2"); wait;
 
input);
 print(
"text3"); wait;
END


Now if you define from the historal view

x: = 9; y = 8; And executes the previous program these values are not called by input

This shows that there are two types of global variables, one visible and one hidden,
Is this good or not?


RE: global variables HP-PPL - Han - 02-24-2017 08:26 PM

It is neither good nor bad. You just need to be aware of the scope of the variables and which has higher priority. It is no different than the following example:

Code:
x:=0;

export myprogram()
begin
  local x;
  x:=2
end;

myprogram() has a local variable named x that has higher priority than the x declared outside of myprogram().