Reference Guide > A Routines > ADDVAR Procedure
  

ADDVAR Procedure
Creates a variable on the $MAIN$ program level and binds a local variable to it.
Usage
ADDVAR, name, local
Input Parameters
name—A string containing the name of a variable to create on the $MAIN$ program level.
Output Parameters
local—The name of the local variable that you want to bind to the variable name on the $MAIN$ program level.
Keywords
None.
Example
This example shows how ADDVAR is used to pass a variable from inside a procedure to the $MAIN$ program level.
PRO test_addvar
; Create a scalar variable inside a procedure, then use ADDVAR
; to pass it to the top-level procedure $MAIN$.
   ADDVAR, 'sclvar', local
   local = 1.2345
   local = local + 1.
   PRINT, local
END
Now, at the WAVE> prompt, do the following:
test_advar
INFO, /Traceback
; PV-WAVE prints: % At $MAIN$.
; Verify that you are now on the $MAIN$ program level.
 
INFO, /Variables
; This INFO command verifies that the scalar created inside the 
; procedure now exists on the $MAIN$ program level.
; PV-WAVE prints: SCLVAR FLOAT = 2.23450

Version 2017.1
Copyright © 2019, Rogue Wave Software, Inc. All Rights Reserved.