Function to get a variable value by name

Hi Everybody,

Is there any function to get a variable value by its name?

Something like this:

color=“red”

IF GETVAL(“CLIENT-NUMBER”) EQ 0
WRITE ‘REQUIRED…’
END-IF

(…)[/color]

You can test an alphanumeric field for a numeric value by using the conditional IS clause and you can move the numeric value from an alphanumeric field using the VAL function:

IF CLIENT-NUMBER IS (N7)
  MOVE VAL(CLIENT-NUMBER) TO #NUMERIC-FIELD
  IF #NUMERIC-FIELD = 0
    WRITE 'REQUIRED'
  END-IF
ELSE
  WRITE 'CLIENT-NUMBER IS NOT NUMERIC'
END-IF

You should always test the field with the IS before attempting to move the value with the VAL.

If that is what you are asking…

I think this is, what samueldc is asking:

define data local
1 #varname (A10)
1 CLIENT-NUMBER (N8)
end-define
#varname := "CLIENT-NUMBER"
if getval(#varname) eq 0  /* get the content of CLIENT-NUMBER
  write 'REQUIRED...'
end-if
end

… and the answer is: No! There’s no such statement. The only thing you can do is to write the whole code dynamically … but this is ugly.

define printer (2) output 'SOURCE'
write (2) 'define data local'
write (2) ...