Programming Tutorial > Task 1–1: Creating a Program
  
Task 1–1: Creating a Program
1. To insert a new program, on the Math tab, in the Operators and Symbols group, click Programming. The programming operators list opens. Click the Program operator . A program structure appears.
2. Type localX.
The local variable localX is defined only within the program. You cannot refer to it outside the program.
3. On the Math tab, in the Operators and Symbols group, click Programming. The programming operators list opens. Click ← Local Assignment and type 5.
This is the local assignment operator. The definition operator is not applicable inside a program.
* 
You can define a local program variable with the same name as a variable in the worksheet but outside the program. PTC Mathcad treats these as two different variables.
4. To evaluate the program, press =. PTC Mathcad displays the evaluation of the last line of the program.
5. Place the cursor at the end of the assignment expression.
6. Press Enter. A new program line appears.
7. Type 2*localX and press F5 to calculate. PTC Mathcad recalculates the program.
* 
No matter how long your program is, the result is always displayed at the top right of the program.
8. To assign the last expression calculated in the program, assign the program to a variable as shown below.
9. Evaluate variables localX and x.
Unlike x, localX is a local variable and its value is unknown outside the program.
Proceed to Task 1–2.