Post Reply 
PPL programming question; local variables
02-13-2014, 04:28 PM (This post was last modified: 02-13-2014 07:15 PM by Han.)
Post: #10
RE: PPL programming question; local variables
(02-13-2014 02:53 PM)CR Haeger Wrote:  Han, thank you again for the reply and the informative articles. They are really helpful for me to start PPL programming.

From my original post, I was really asking if replacing

THIRDANG(a,b) with THIRDANG(angle1, angle2) would prevent angle1 and angle2 from being passed to the ANG() subroutine.

I thought declaring LOCAL angle1, angle2; would allow this, but maybe not.

Best,
Carl

In terms of priority, the angle1 and angle2 variables within THIRDANG() have higher priority over angle1 and angle2 declared toward the top. Unlike app variables, which can be fully named via Appname.variablename, there is no mechanism to reference the angle1 and angle2 declared outside of a procedural block if you also use local variables of the same name within said procedural block. In general, a local variable declared inside a procedural block will have highest priority.

You can confirm this with (updated):
Code:

SUBPRG();
LOCAL var1=1, var2=2;

EXPORT MYPROG(var1,var2)
BEGIN
  PRINT(var1 + " " + var2);
  WAIT(-1);
  SUBPRG();
END;

SUBPRG()
BEGIN
  PRINT(var1 + " " + var2);
  FREEZE;
END;

If you run MYPROG(-1,-2) then you will see that MYPROG prints -1,-2 even though var1 and var2 were initialized to 1 and 2 respectively. Moreover, the var1 and var2 values declared outside of MYPROG are still retained (they are distinct from those declared within the definition of MYPROG. Hence SUBPRG prints 1, 2.

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


Messages In This Thread
RE: PPL programming question; local variables - Han - 02-13-2014 04:28 PM



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