
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
I'm using a product called MPACT from ESI. With MPACT I am able to create screens for our users to interact with. It also allows gives me places where I can interact with the dialog. The interaction points are written in cobol and MPACT compiles our code using the Visual Cobol compiler, but only uses the native aspect of it. I have this MPACT program calling a Visual Cobol Winform program. Inside of the Winform program I am doing an accept from the command line. All of my parameters are showing up, but if I have a filler that has spaces in it then they are being truncated.
I've attached the code that is in the MPACT program and the code that is in the winform program
We are using Visual Cobol 2.2.
Accepted Solutions

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
In scenario 1 you are doing:
set passed-to-program2 to type Environment::CommandLine.
accept passed-to-program2 from command-line.
where you should only be doing
set passed-to-program2 to type Environment::CommandLine.
the accept statement is overriding the value that is coming in from the set statement so remove the accept any then you should see the value that is being passed.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
Forgot to mention that this was working until yesterday. The problem started after I recompiled both the MPACT program and the winform program.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
This appears to be a difference in the way that the command-line is returned between a native program and a managed program.
In a managed program, even a console application extra spaces are removed from the command line because it is assumed that these are individual parameters separated by a space so it reduces multiple spaces to a single space.
I tested this in 2.1 update 1 and it has the same behavior as 2.2.
You can make it return the entire command line as is by enclosing the parameters within quotes when passed in.
myprog.exe "11111 22222 333333"
when this is returned to the managed program via:
accept my-command from command-line
my-command will contain the entire string including the enclosing quotes so those will have to be removed.
Something like:
unstring my-command(2:) delimited by quote
into passed-to-program
If you did not wish to change the calling program to include the quotes then you could alternatively use:
set my-command to type Environment::CommandLine
my-command would then contain the entire command line including the program name so you would need to get rid of that.
Something like:
perform varying sub1 from length of my-command by -1 until sub1 = 0
if my-command(sub1:1) = '"'
add 2 to sub1
exit perform
end-if
end-perform
move my-command(sub1:) to passed-to-program
Thanks.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
Not sure what I am doing wrong. Here is what I tried. I have 2 scenarios. I didn't try the quotes because if I go this route I only have to change one program. Thanks
Scenario 1
01 passed-to-program2 type String.
set passed-to-program2 to type Environment::CommandLine.
accept passed-to-program2 from command-line.
if passed-to-program2 not = spaces
*> it is going into here and I do use a dialogresult to display to the screen and it
is truncating the spaces just as before?
Scenario 2
01 passed-to-program.
05 ptp-policy-num pic x(07) value spaces private.
05 filler pic x(01) value spaces private.
05 ptp-ins-type pic x(01) value spaces private.
05 filler pic x(05) value spaces private.
05 ptp-program-name pic x(10) value spaces private.
05 filler pic x(30) value spaces private.
set passed-to-program to type Environment::CommandLine.
move spaces to passed-to-program.
accept passed-to-program from command-line.
if passed-to-program not = spaces
*> this is also truncating the spaces

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
In scenario 1 you are doing:
set passed-to-program2 to type Environment::CommandLine.
accept passed-to-program2 from command-line.
where you should only be doing
set passed-to-program2 to type Environment::CommandLine.
the accept statement is overriding the value that is coming in from the set statement so remove the accept any then you should see the value that is being passed.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
That worked. Thank you very much.