Variable Introspection

EdInTheUK

New Member
Hello. I'm wondering if there's any way at run time to determine the format of a variable. I'm looking to find the display width of a character parameter passed into a procedure.
I'm unable to 1) find any way to do this via searching google / this forum. 2) unable to find a way to render the variable so that it implicitly uses it's formatter, which would be a roundabout way of, at least, finding the width.
It looks like variable formatters are only used at compile time to assemble frames etc - at run time the information is lost?
 
Is this what you mean?

Code:
def var xxx as c format "X(20)".
form xxx with frame y.
disp xxx:FORMAT xxx:WIDTH-CHARS with frame y.
 
A variable can have a display format. When passing a variable into a procedure, the display format is determined by the parameter definition. You can additionally pass the format of the variable as a character variable:

Code:
DEF VAR ii AS INT FORMAT "9999" LABEL "variable".


DISPLAY ii.


RUN blaat ( ii, ii:FORMAT ).


PROCEDURE blaat:
   DEF INPUT PARAMETER i_ii      AS INTEGER FORMAT ">>>9" LABEL "parameter".
   DEF INPUT PARAMETER i_cformat AS CHARACTER.


   DISPLAY 
      i_ii
      STRING( i_ii, i_cformat )
      .


END PROCEDURE.
 
Back
Top