Tests if an inputexpression has a nonzero value.
It can also be used to test whether an expression evaluates to zero, or whether a variable has been set.
IF KEYWORD_SET(x) THEN PRINT, 'It is set' ELSE PRINT, 'Not set'
Not set
x
has not been initialized. On the other hand, if you set x
to a specific value, say 2, you will see:
x = 2 IF KEYWORD_SET(x) THEN PRINT, 'It is set' ELSE PRINT, 'Not set' It is set
FUNCTION SQUARE_IT, Value, Print_Flag = Print
Squared_Val = Value * Value
IF (KEYWORD_SET(Print)) THEN PRINT, Squared_Val
RETURN, Squared_Val
END
WAVE
prompt:
.RUN SQUARE_IT.PRO y = SQUARE_IT(5) PRINT, y
25
y = SQUARE_IT(10, /Print_Flag)
100