45 pts.
 Problem with CMD/CL and *PNAME type (Path name contains embedded nulls.)
So I am giving a good effort into writing a CL/CMD pair to start one of our programs from the command line, but I've hit a snag.  Here is my CMD source:

CMD PROMPT('Start Engine')

PARM KWD(PGM)      TYPE(*NAME)  LEN(10) DFT('TRAN_ENGV2') PROMPT('Engine Program Name')
PARM KWD(PATH)     TYPE(*PNAME) MIN(1) PROMPT('IFS Directory')
PARM KWD(PORT)     TYPE(*INT2)  MIN(1) PROMPT('Listening Port')
PARM KWD(NUMCHLD)  TYPE(*INT2)  MIN(1) PROMPT('Number Of Children To Start')
PARM KWD(JOBNAME)  TYPE(*NAME)  LEN(10) DFT('DFCENG') PROMPT('Name of this job')

and the first few lines of my CL:

PGM PARM(&ENG_PROG &PATH &PORT &NUMCHLD &JOBNAME)
                                                 
    DCL VAR(&ENG_PROG) TYPE(*CHAR) LEN(10)      
    DCL VAR(&PATH) TYPE(*CHAR) LEN(1000)        
    DCL VAR(&PORT) TYPE(*UINT)                  
    DCL VAR(&NUMCHLD) TYPE(*UINT)                
    DCL VAR(&JOBNAME) TYPE(*CHAR) LEN(10)        

The &PATH parameter, as it comes into the CL, has garbage in it, hence the "Path name contains embedded nulls." problem.

Questions:
1.  Can anyone help me with this?  Seems like the problem is in the CMD source.
2.  What is the real value of using *PNAME?  Can't I just use *CHAR here?

Software/Hardware used:
i7 V7R1 CL CMD
ASKED: October 10, 2012  3:30 PM
  Help
 Approved Answer - Chosen by DraeByllek (Question Asker)

Your program declares the variable &PATH to be 1000 characters long. Your command only defines the first few bytes. Because of that, your program is accessing undefined memory for most of the 1000 bytes. You'd do well to read the documentation of a CL PARM statement to see how to specify parameter lengths. -- Tom

ANSWERED:  Oct 10, 2012  8:09 PM (GMT)  by DraeByllek

 
Other Answers:
Last Wiki Answer Submitted:  October 10, 2012  3:31 pm  by  DraeByllek   45 pts.
Latest Answer Wiki Contributors:  DraeByllek   45 pts.
To see other answers submitted to the Answer Wiki: View Answer History.


Discuss This Question:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _