Page 21-36
Example 3 – tagging input and output from function p(V,T)
In this example we modify the program
@@@p@@@
so that the output tagged input
values and tagged result. Use
‚
@@@p@@@
to recall the contents of the program
to the stack:
«
“
Enter V, T, and n:
“
{
“
:V:
:T:
:n:
“
{2 0} V }
INPUT OBJ
→
→
V T n
‘
(8.31451_J/(K*mol))*(n*T/V)
‘
»
Modify it to read:
«
“
Enter V, T and n:
“
{
“
:V:
:T:
:n:
“
{2 0} V }
INPUT OBJ
→
→
V T n
«
V T n
‘
(8.31451_J/(K*mol))*(n*T/V)
‘
EVAL
“
p
”
→
TAG
»
»
Note
: Notice that we have placed the calculation and tagging of the function
p(V,T,n), preceded by a recall of the input variables V T n, into a sub-program
[the sequence of instructions contained within the inner set of program
symbols
«
»
]. This is necessary because without the program symbol
separating the two listings of input variables (
V T N
«
V T n)
, the program
will assume that the input command
→
V T N V T n
requires six input values, while only three are available. The result would
have been the generation of an error message and the interruption of the
program execution.
To include the subprogram mentioned above in the modified definition of
program
@@@p@@@
, will require you to use
‚å
at the beginning and end of
the sub-program. Because the program symbols occur in pairs, whenever
‚å
is invoked, you will need to erase the closing program symbol (
»
) at
the beginning, and the opening program symbol (
«
) at the end, of the sub-
program.