beautypg.com

Using global variables, Example, Using global variables -11 – HP 49g Graphing Calculator User Manual

Page 197: Examples -8, Using, 0©00®i)a

Attention! The text in this document has been recognized automatically. To view the original document, you can use the "Original mode".

background image

Using

global variables

You can use existing global variables in your pi-ograms. Global variables

are different to local variables in the following ways:

• Global variables are available to the entire program, independent of

nested procedures.

• Unlike local variables, you can create more than one global variable in

a nested procedure.

Within a program, you use the (Fn>) key to define a global variable. The

^ key produces a ^ symbol on the command line.

Example

The following program demonstrates the use of a global variable to hold

the data a program uses, and to hold the output it produces. It performs
the following tasks:

• It accepts an input argmnent and calculates its percentage of a value in

the global variable “TOTL”. You create TOTL before you mn the
program.

• It stores the result into another global variable, “RESLTl”.

• It converts the numeric result to a string and adds “%” for readability.

To create the program, perfonn the following:

1. Insert the program delimiters onto the command line and define the

input variable.

0©00®i)A

« ^ A

2. Create a new nested procedure.

0

@

Introduction to programming

Page 10-11