HP Forums

Full Version: global variables HP-PPL
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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?
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().
Reference URL's