Local Definition
In the image at right the formula for circumference of a
circle is defined in a Mathcad Program using Mathcad
Prime’s Local Definition operator . In this case
the use of the Local Definition helps to clarify the
meaning of the program named C. C accepts a single
parameter, the measurement of a diameter of the circle.
During program execution Circumference is calculated
using the formula π*D. C returns the value of
Circumference, the last value calculated. But, since it is
defined locally, the value of Circumference is undefined
outside of the program definition. Therefore,
Circumference is undefined on the worksheet and
returns an error when evaluated.
Follow these steps to create a Mathcad program that calculates the area of a circle given its
Diameter as an input parameter:
Step 1: Type the following keystrokes to give the program a name and a parameter:
A(D: You should see this on the worksheet:
Step 2: Mathcad shows that it is waiting for the program to be defined on the right side of the assignment
statement by leaving the blue cursor in the placeholder. Follow these steps to insert the first line of the
program:
Left-click to select the Math ribbon
Left-click on the Programming icon
Left-click the Insert Program Structure
icon on the Programming menu
Type: radius in the placeholder
Left-click on the Programming icon on the Math ribbon
Left-click on the Local Assignment Operator icon on the
Programming menu
Type: D/2 in the placeholder. Hit the Right Arrow key once to
advance the cursor and then hit the ENTER key. A new Program
line will appear as shown.
Programming with Mathcad Prime | pg. 3