; docformat = 'rst' ;+ ; Prints value of argument before and after it is incremented. The real test of ; how the argument is passed is what the value is after the routine is ; exited. ; ; :Params: ; x : in, out, required, type=numeric ; example argument ;- pro mg_by_reference_test, x compile_opt strictarr print, 'Passed as ' + (arg_present(x) ? 'named variable.': 'expression.') print, 'Before, value = ' + strjoin(strtrim(x, 2), ', ') x++ print, 'After, inside routine, value = ' + strjoin(strtrim(x, 2), ', ') end ; b is passed by reference since b is a named variable a = 5 mg_by_reference_test, a print, 'After, outside routine, value = ' + strjoin(strtrim(a, 2), ', ') print ; arr is passed by reference since arr is a named variable arr = fltarr(3) mg_by_reference_test, arr print, 'After, outside routine, value = ' + strjoin(strtrim(arr, 2), ', ') print ; arr[0] is passed by value since arr is an expression mg_by_reference_test, arr[0] print, 'After, outside routine, value = ' + strjoin(strtrim(arr[0], 2), ', ') end