Post Reply 
PPL programming question; local variables
02-13-2014, 12:22 AM (This post was last modified: 02-13-2014 01:17 AM by CR Haeger.)
Post: #1
PPL programming question; local variables
Hello,

Thanks to HAN for preparing this excellent guide: http://www.hpmuseum.org/forum/thread-216.html

I'm new at PPL programming and made it through all but the last program. The following code runs fine and is based on Part IV #2 code Han provided.

PHP Code:
// program declarations 
THIRDANG(); 
ANG(); 

// Local variables
LOCAL angle1angle2

// THIRDANG(a,b) // Takes two angles a and b (in radians) of a triangle and // returns the third angle (in degrees) 
EXPORT THIRDANG(a,b//<-- ** Can I change this to THIRDANG(angle1, angle2)?

BEGIN   
  angle1
:=a;   // <-- ** Can I delete this?
  
angle2:=b;   // <-- ** Can I delete this?
  
IF HAngle==0 THEN
    ANG
();
  
END;   
  RETURN(
180-angle1-angle2); 
END

// ANG() // Takes an angle a (in radians) and returns the same angle in degrees 
ANG() 

BEGIN   
  angle1
:=angle1/PI*180;   
  
angle2:=angle2/PI*180
END

But, if I try to shorten the code to the following, it appears that the local variables are not passed to the ANG() subroutine when it is called. Why not?

PHP Code:
// program declarations 
THIRDANG(); 
ANG(); 

// Local variables
LOCAL angle1angle2

// THIRDANG(a,b) // Takes two angles a and b (in radians) of a triangle and // returns the third angle (in degrees) 
EXPORT THIRDANG(angle1angle2//<--  edited
BEGIN   
     
// angle1:=a; <-- Deleted
     // angle2:=b; <-- Deleted
  
IF HAngle==0 THEN
    ANG
();
  
END;   
  RETURN(
180-angle1-angle2); 
END

// ANG() // Takes an angle a (in radians) and returns the same angle in degrees 
ANG() 

BEGIN   
  angle1
:=angle1/PI*180;   
  
angle2:=angle2/PI*180
END

Best,
Carl

** Updated second code...
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
PPL programming question; local variables - CR Haeger - 02-13-2014 12:22 AM



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