Archive for category HP-48G
Let’s continue our HP-48 programming course, this time I’m going talk about variable declaration. A variable is where data is stored temporally, therefore programs can process them. In USER-RPL language, you can local, global or environment variables.
Programs use this kind of variables in order to do internal operations. Let’s see an example:
Here, variables ONE and TWO have the values 1 and 2 respectively. Later, inside the program they are used to perform an addition which answer is left on the calculator’s stack.
If you define a global variable, it can be used in the current program and it can also be used by other programs that were invoked from the current one. I modified the latter example to use an external program which perform the addition, called PLUS:
The PLUS program invokes global variables and performs the addition, as is showed in here:
This kind of declaration has no limit on variable’s scope, because it’s defined as global. But it has a downside effect: programs that use that type of declaration will be be bigger than those which not.
The environment variables are the ones you can use from the current working directory. For instance, values 1 and 2 can be stored in the current directory using ONE and TWO as named, and you can edit the PLUS program to use these variables: