Renames a PV-WAVE variable.
new_name A string specifying the name of the new variable. By default, the new variable is placed at the $MAIN$ program level.
If n 0, the level count is relative, counting from the current procedure back to the $MAIN$ level.
To rename a variable that exists at a level other than the current level,use the UPVAR command to bind that variable to a local variable.
orig = 1B RENAME, orig, 'new' INFO, new new BYTE = 1
To run this example, follow the steps below.
Copy or type the code for the TESTRENAME and TESTLEVEL2 procedures into a file called
testrename.pro
.
PRO TESTRENAME; This procedure tests the RENAME procedure first inside the local ; program level (level 1), and then by renaming variables on other; program levels.
orig1 = 'Original Level 1 Variable' INFO, Depth = d; First, create a variable in the local program level, and verify that the ; program level is level 1.
RENAME, orig1, 'orig1_new', Level = d; Rename the variable inside the local scope of TESTRENAME.
INFO, orig1_new; Verify that RENAME created the new variable.
UPVAR, 'orig0', orig_level1
TESTLEVEL2
INFO, local_level1
PRINT, local_level1 END PRO TESTLEVEL2 INFO, /Depth; First, verify that the local scope is program level 2.
UPVAR, 'orig_level1', orig_level2, Level = -1; Use UPVAR to pass the variable orig_level1 from program level 1; to the current program level 2. Note the use of the Level keyword, ; which causes UPVAR to look one program level down from the current; level to find the variable.
RENAME, orig_level2, 'new', Level = 2; Rename the variable that was just passed into program level 2. ; The Level keyword specifies that the renamed variable be placed in; program level 2.
INFO, new; Verify that the new variable exists in the local scope.
local_level2 = INDGEN(10) + 222; Simply create a new variable within the current scope (level 2).
RENAME, local_level2, 'local_level1', Level = -1; Rename this variable, but put the renamed version on a different ; program level. The Level keyword accomplishes this. It specifies that ; the renamed variable be placed one program level down from the ; current level. The current program level is 2, so the new variable is ; placed in program level 1.
RENAME, new, 'new_main'; Finally, use RENAME to rename a variable in the current scope (level 2); and place the renamed variable in program level 0 ($MAIN$). Note that; program level 0 is where RENAME places renamed variables by default,; unless the Level keyword is used.
END
WAVE
prompt, compile the test procedures with .RUN.
.RUN testrename % Compiled module: TESTRENAME. % Compiled module: TESTLEVEL2.
orig0 = 'Original Level 0 Variable'
TESTRENAME PROGRAM LEVEL = 1 ORIG1_NEW STRING = 'Original Level 1 Variable' PROGRAM LEVEL = 2 NEW STRING = 'Original Level 0 Variable' LOCAL_LEVEL1 INT = Array(10) 222 223 224 225 226 227 228 229 230 231
INFO, new_main new_main STRING = 'Original Level 0 Variable'