Compilesand executes one or more PV-WAVE statements contained in a string at run-time.
Function EXECUTE is used to invoke both the user-defined function of two variables and the user-defined printing procedure. The name of the function is passed to TABLE using keyword Func, and the name of the printing procedure is passed using keyword Prt_Pro. The following is a listing of TABLE:
PRO TABLE, x, y, Func = func, Prt_Pro = pp tab = FLTARR(3, n_elements(x)) tab(0, *) = x tab(1, *) = y val = EXECUTE('tab(2, *) = ' $ + func + '(tab(0, *), tab(1, *))')
IF val EQ 1 THEN BEGIN
val = EXECUTE(pp + ', tab')
IF val EQ 0 THEN BEGIN
PRINT, "***Error in execution of " + $ "printing procedure! ***"
ENDIF
ENDIF ELSE BEGIN
PRINT, "*** Error in execution of " + "function! ***"
ENDELSE END
table.pro
in your working directory, it will be compiled automatically when it is invoked. Note that the string concatenation operator, along with several string literals, are used to construct the statements to execute using EXECUTE.The user-defined function requires two arguments, which are the values of the independent variables of the function. The function should return the result of the function evaluation. The user-defined printing procedure requires one argument, which is the two-dimensional table to be printed. The following commands can be entered at the interactive prompt to create and compile a function of two variables:
.RUN - FUNCTION fcn, x, y - RETURN, x^2 - y^2 - END
PRO prt, arr PRINT, Format = $ '(4x, "x", 13x, "y", 10x, "func(x, y)")' PRINT, Format = '(39("-"))' PRINT, Format = '(2(f9.4, 5x), f10.4)', arr END
prt.pro
in your working directory, it will be compiled automatically when it is invoked. The following commands can be used to create the vectors of values at which to evaluate fcn and to invoke TABLE:
x = [1, 2, 3, 4, 5] y = REVERSE(x) TABLE, x, y, Func = 'fcn', Prt_pro = 'prt' x y func(x, y) --------------------------------------- 1.0000 5.0000 -24.0000 2.0000 4.0000 -12.0000 3.0000 3.0000 0.0000 4.0000 2.0000 12.0000 5.0000 1.0000 24.0000