ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

Cl - call command with parameters passing wrong value

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

  • Cl - call command with parameters passing wrong value

    Hi All,


    I created the program with below 3 parameters and calling the program from command line as -
    CALL PGM(MYPROGRAM) PARM('ABCDEFGHIJ' '/ROOT/HOME/MYNAME.TXT' 'ABCDEF')

    DCL VAR(&A) TYPE(*CHAR) LEN(10) VALUE(' ')
    DCL VAR(&B) TYPE(*CHAR) LEN(255) VALUE(' ')
    DCL VAR(&C) TYPE(*CHAR) LEN(05) VALUE(' ')

    Here the issue is with the value coming into the variable &B. the actual value I am passing value to the variable &B thru call command is ?/ROOT/HOME/MYNAME.TXT'. But the value coming into the program for variable &B is as below.


    EVAL &B
    &B =
    ....5...10...15...20...25...30...35...40...45...50 ...55...60
    1 '/ROOT/HOME/MYNAME.TXT ABCDEF '
    61 ' '
    121 ' '
    181 ' '
    241 ' '

    I am not sure why the value of &B is coming along with &c value in to the program
    Please clarify me what I am doing wrong here .

    Regards,
    Girish

  • #2
    Re: Cl - call command with parameters passing wrong value

    Hi Girid:

    This is a known issue caused by a character variable being > 32 characters long.
    The easiest solution is to wrap the cl in a command and run the command.
    I've seen other solutions that place a character in position 256 of the variable that is 255 long.

    Search the web for "clle 32" for an explanation of the cause of the issue.

    Best of Luck
    GLS
    The problem with quotes on the internet is that it is hard to verify their authenticity.....Abraham Lincoln

    Comment


    • #3
      Re: Cl - call command with parameters passing wrong value

      Indeed - the CALL statement makes some assumptions on data being passed. Make a CMD with the parameters,specifying the lengths and types and run it as a command and it will work as you expect.

      Comment


      • #4
        Re: Cl - call command with parameters passing wrong value

        You could also specify the full 255 length between the ' ' on the CALL statement
        Code:
        CALL PGM(MYPROGRAM) PARM('ABCDEFGHIJ' '/ROOT/HOME/MYNAME.TXT                                                                                                                                                                                                                                          ' '21' 'ABCDEF')
        which is cumbersome but okay if this is just a quick test. Watch out for line breaks when you paste into green screen

        You can also specify a 4th parameter that is the length of the 255 parm
        CALL PGM(MYPROGRAM) PARM('ABCDEFGHIJ' '/ROOT/HOME/MYNAME.TXT' '21' 'ABCDEF')
        then use %SST to move the 1st 21 characters of &B into a different, internally defined len 255 field
        I always assumed this CLLE 32 issue is why iSeries APIs like QCMDEXC that have large text parameters, also have an extra parameter for the length

        Comment


        • #5
          Re: Cl - call command with parameters passing wrong value

          All that work when you can create a simple CMD with the same name as the program (MYPROGRAM in the given example).

          Code:
          CMD        PROMPT('My program with three parms')           
          PARM       KWD(A) TYPE(*CHAR) LEN(10) PROMPT('Parameter +  
                       A')                                           
          PARM       KWD(B) TYPE(*CHAR) LEN(255) PROMPT('Parameter + 
                       B')                                           
          PARM       KWD(C) TYPE(*CHAR) LEN(5) PROMPT('Parameter +   
                       C')

          Comment


          • #6
            Re: Cl - call command with parameters passing wrong value

            I agree with GLS and Rocky. My favorite way to handle this is to write a command. I like the command interface very much.

            I also wrote a utility that formats the parameters the way they should be. I use it occasionally when I don't need a command interface.

            http://www.itjungle.com/fhg/fhg110106-story02.html

            Comment


            • #7
              Re: Cl - call command with parameters passing wrong value

              Originally posted by TedHolt View Post
              I agree with GLS and Rocky. My favorite way to handle this is to write a command. I like the command interface very much.

              I also wrote a utility that formats the parameters the way they should be. I use it occasionally when I don't need a command interface.

              http://www.itjungle.com/fhg/fhg110106-story02.html




              Thank you All

              Comment

              Working...
              X