Define calculatearea()=
Prgm
area:=wt*ht
EndPrgm
•
Embed the values directly in the object itself.
Define calculatearea()=
Prgm
wt:=3
ht:=23
area:=wt*ht
EndPrgm
•
Use parameters in the definition. This lets users pass one or more
values as arguments to the object when they use it.
Define calculatearea(wt,ht)=
Prgm
area:=wt*ht
EndPrgm
Example of passing values to a program
The following program,
values must be passed to the program. The first value must be the height,
and the second value must be the radius.
When you define the program in the Program Editor, you specify in
parentheses the parameters that will be used to store the passed values.
The parameters are placeholders, so their order is important. The names
you choose should be names that remind you which information to
supply.
1.
Define the
volcyl
Define volcyl(height,radius) =
Prgm
Disp "Volume =", approx(
height)
EndPrgm
Programming
, calculates the volume of a cylinder. Two
volcyl
program.
p ¦
2
¦
radius
329