ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

determine the length of variable.

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • determine the length of variable.

    hi every one.

    is there is any way to determine the length of the variable 'C' as follows..

    eval C = %trim(A)

    here the length of the varible C should be the trimed string's length.

    ex:

    A = 'MUKUNDAN ' the length of A is 10.

    then C Should be like

    C='MUKUNDAN'
    here how to determine the length of C as a varible.

  • #2
    Re: determine the length of variable.

    You can use %LEN(%TRIM(C))

    find below a code example.

    Code:
    DZVAR1            S              5A    INZ('ABC')                            TEST VARIABLE  
    DZVAR2            S              5S 0                                        TEST VARIABLE   
     *                                                                                           
    C                   EVAL      ZVAR2 = %LEN(%TRIM(ZVAR1))                                          
    C     ZVAR2         DSPLY
    now Zvar2 will hold the value 3 and not 5.
    Regards,
    KR

    Comment

    Working...
    X