sponsored links

Collapse

Announcement

Collapse
No announcement yet.

QCMDCHK with library?

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

  • QCMDCHK with library?

    I'm using QCMDCHK to allow prompting for a command in the middle of an RPGLE program, and I'm running across a problem. Sometimes, the commands in question might not be in the current library list, so the library might be explicitly defined:

    SAMPLELIB/WRKTMPCMD

    Where do I put the question mark, when passing to QCMDCHK? I've tried ?SAMPLELIB/WRKTMPCMD; I've tried SAMPLELIB/?WRKTMPCMD. Both give me errors. If I leave the library off, ?WRKTMPCMD works -- but only if the WRKTMPCMD happens to be in the library list.

    Any ideas? I'm coming out of an RPGLE, but that shouldn't matter.

  • #2
    Re: QCMDCHK with library?

    Maybe a dumb question, but why wouldn't you just put the command in a production library that will always be in the user's library list?

    Regardless, I might attack it a different way. I would probably just do an ADDLIBLE *LAST before the command is to execute. MONMSG or MONITOR for the fact that the library may be in the list already and you're good to go.

    Sorry, I am not much help on the specific answer you're seeking.

    Comment


    • #3
      Re: QCMDCHK with library?

      We've got commands scattered all over the system. Person A prompting the command (for purposes of putting it on a menu, actually) might not be the person who eventually runs it -- and Person A might not have actual authority to do so.

      But you've got the beginnings of an idea, there. I would have to move the QCMDCHK into a CLLE. I do an ADDLIBLE *LAST before running QCMDCHK -- and MONMSG for failure. Then after, I do a RMVLIBLE iff the ADDLIBLE succeeded. (Better to go to a CLLE than try to do this with string manipulation in RPGLE).

      Thanks!

      Comment


      • #4
        Re: QCMDCHK with library?

        I rarely write new CL anymore. It's extremely easy to run CL commands in RPG and monitor for errors, so I do that almost exclusively anymore.

        http://www.code400.com/forum/showthr...RPGLE(QCMDEXC)

        A lot of good examples around of how to do this.

        Comment


        • #5
          Re: QCMDCHK with library?

          You put the ? first (before the library).

          I just did a quick test, and it worked fine.

          Code:
          PGM
          
             DCL VAR(&CMD) TYPE(*CHAR) LEN(3000)
          
             CHGVAR VAR(&CMD) VALUE('?QSYS/WRKSPLF')
             CALL QCMDCHK PARM(&CMD 3000)
          
          ENDPGM
          Does this really not work for you?

          Comment


          • #6
            Re: QCMDCHK with library?

            An alternative could be to look for the command in your program using the QUSLOBJ API and then add the library to the library list?

            Chris...

            Comment


            • #7
              Re: QCMDCHK with library?

              Originally posted by Alan S. Binkow
              Where do I put the question mark, when passing to QCMDCHK? I've tried ?SAMPLELIB/WRKTMPCMD; ... give{s} me errors..
              That should work fine. We'd need to see the code that does it (including referenced data definitions) and possibly message IDs of any errors in order to say what might be wrong.
              Tom

              There are only two hard things in Computer Science: cache invalidation, naming things and off-by-one errors.

              Why is it that all of the instruments seeking intelligent life in the universe are pointed away from Earth?

              Comment

              sponsored links

              Collapse

              Working...
              X