Data editing > Creating new variables > Naming variables in your program
 
Naming variables in your program
An alternative method of naming variables is to define them as part of your Quantum program. Variables which you want to use within your program and which you want to be able to change in a subroutine must be defined before the ed statement. These are called external variables. Variables which are to be used during the edit, and whose values may be passed to a subroutine but not changed by it may be defined after the ed statement. These are termed local variables.
For more information about external and local variables, see Passing information between the edit and a subroutine.
Example
/* pints and liters are external variables because they are
/* defined outside the edit. Their values may be changed by
/* the subroutine conv.
int pints 1
real liters 1
ed
/* cost is a local variable which may only be changed in the edit,
/* not by a subroutine. Its value may be passed to the subroutine
/* for use in calculations
int cost 1
    .
/* count pints bought per week
    .
/* convert pints to liters
call conv
/* calculate cost @ 21 pence per liter
cost = liters * 21
return
subroutine conv
/* statements comprising subroutine conv go here
return
end
See also
Creating new variables