Uuumm, may be the CL is the problem. I call the C program straight from
command line and it works fine (no junk in stdout). I guess the
debugger lie to me.

When I call the C program thru the CL program and do below in debugger
eval *argv[1] :s

it shows me
*argv[1] :s = "NOCC07QA "

I though :s tells debugger that the pointer is a null terminator string.
How can debugger show correct data if there is no terminator on position
30 of argv[1]?


Anyway, I change the CL to be as below and it appears to correct the
problem.
PGM PARM(&HOST &PORT &LIBNAME &LOCK)
DCL VAR(&HOST) TYPE(*CHAR) LEN(10)
DCL VAR(&PORT) TYPE(*CHAR) LEN(4)
DCL VAR(&LIBNAME) TYPE(*CHAR) LEN(10)
DCL VAR(&LOCK) TYPE(*CHAR) LEN(10)
DCL VAR(&C_HOST) TYPE(*CHAR) LEN(30)
DCL VAR(&C_PORT) TYPE(*CHAR) LEN(30)
DCL VAR(&NULL) TYPE(*CHAR) LEN(1) VALUE(X'00')

CHGVAR VAR(&C_HOST) VALUE(&HOST *CAT &NULL)
CHGVAR VAR(&C_PORT) VALUE(&PORT *CAT &NULL)
CALL PGM(&LIBNAME/ECD_STP3) PARM(&C_HOST &C_PORT '50000')
ENDPGM


Simon & Scott thank you for your help


"Lim Hock-Chai" <Lim.Hock-Chai@xxxxxxxxxxxxxxx> wrote in message
news:<mailman.4935.1216908129.6762.c400-l@xxxxxxxxxxxx>...
Scott,
RUN_ECDSTP is actually a CL program which in turn calls the C program.
Below are relevent code in this CL:

PGM PARM(&HOST &PORT &LIBNAME &LOCK)
DCL VAR(&HOST) TYPE(*CHAR) LEN(10)
DCL VAR(&PORT) TYPE(*CHAR) LEN(4)
DCL VAR(&LIBNAME) TYPE(*CHAR) LEN(10)
DCL VAR(&LOCK) TYPE(*CHAR) LEN(10)
DCL VAR(&C_HOST) TYPE(*CHAR) LEN(30)
DCL VAR(&C_PORT) TYPE(*CHAR) LEN(30)

CHGVAR VAR(&C_HOST) VALUE(&HOST)
CHGVAR VAR(&C_PORT) VALUE(&PORT)
CALL PGM(&LIBNAME/ECD_STP3) PARM(&C_HOST &C_PORT '50000')
ENDPGM



I'm still not sure if the CL call is the problem, because the data looks
ok in debug (See below for screen shot). It just not look right in
stdout.
Display Module Source



Program: ECD_STP3 Library: PALHC Module: ECD_STP3

410 "Can't open member file ECDSTP
Output
411 sendEscapeMessage(log_msg, log_msg_length);

412 exit(-1);

413 }

414 sprintf(printThisBuf, "argv[0]->%s\n", argv[0]);

415 printThis(printThisBuf);

416

417 sprintf(printThisBuf, "argv[1]->%s\n", argv[1]);

418 printThis(printThisBuf);

419

420 sprintf(printThisBuf, "argv[2]->%s\n", argv[2]);

421 printThis(printThisBuf);

422

423 sprintf(printThisBuf, "argv[3]->%s\n", argv[3]);

424 printThis(printThisBuf);


More...
Debug . . .



F3=End program F6=Add/Clear breakpoint F10=Step F11=Display
variable
F12=Resume F17=Watch variable F18=Work with watch F24=More
keys
*argv[1] :s = "NOCC07QA "



The actual program is quite big. I used your version and call it from a
mark up CL and it works fine.




"Scott Klement" <c400-l@xxxxxxxxxxxxxxxx> wrote in message
news:<mailman.4828.1216853437.6762.c400-l@xxxxxxxxxxxx>...
Hi Lim,

Sorry, I did not cut and paste the code correctly in my OP. Below
is
what the code looks like

I can't see anything wrong with your code, and indeed, I tried it on
my
own system, and did not have the problem you've described. However,
since the code you posted wasn't a complete program, I had to add some

code to make it work (maybe that makes it different)?

What Simon says is true, of course. But, I'm not sure that it applies

to your situation, since you stated that you were calling it with the
following command (this is a copy/paste from your message):

CALL PGM(*LIBL/RUN_ECDSTP) PARM('NOCC07QA' '5553' '*LIBL' UA_STP3)

Since all of your parms are literals on the command-line, and not
variables from another program, they should all be null-terminated
properly. And, indeed, when I ran your code, I didn't see any
garbage.

Here's the code I test with:


#include <stdio.h>
#include <string.h>
#include <time.h>


int get_time_stamp(char sString[])
{
time_t thetime;
struct tm *usetime;
char sTime[20];

time(&thetime);
usetime=localtime(&thetime);
sprintf(sTime,"%02d/",usetime->tm_mon+1);
sprintf(sTime+3,"%02d/",usetime->tm_mday);
sprintf(sTime+6,"%4u ", usetime->tm_year + 1900);
sprintf(sTime+11,"%02d:",usetime->tm_hour);
sprintf(sTime+14,"%02d:",usetime->tm_min );
sprintf(sTime+17,"%02d",usetime->tm_sec );
strcpy(sString,sTime);
return(1);
}


void
printThis(char *text)
{
char stime[20];

memset(stime, 0x0, sizeof(stime));
get_time_stamp(stime);
printf("%s %s\n", stime, text);
}


int main(int argc, char **argv) {

char printThisBuf[110];

sprintf(printThisBuf, "argv[0]->%s\n", argv[0]);
printThis(printThisBuf);

sprintf(printThisBuf, "argv[1]->%s\n", argv[1]);
printThis(printThisBuf);

sprintf(printThisBuf, "argv[2]->%s\n", argv[2]);
printThis(printThisBuf);

sprintf(printThisBuf, "argv[3]->%s\n", argv[3]);
printThis(printThisBuf);

return 0;
}

----------

This thread ...

Follow-Ups:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2019 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].