Highlighted
Absent Member.
Absent Member.
1348 views

[archive] command line

[Migrated content. Thread originally posted on 19 March 2003]

I want to now witch command line start the application like
wrun32.exe -wd -C c:\lcm\\CBLCONFI utmenu

I am searching a way to have -wd -C c:\lcm\cblcondi utmenu
0 Likes
4 Replies
Highlighted
Absent Member.
Absent Member.

RE: [archive] command line

Dear Micr4517,

it is sometimes hard to figure what your question is, could you please try to use more words, possibly examples to illustrate what you are after?
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: [archive] command line

I try accept ws-command from command-line this return the command line after the program what i am searching is command line from the runtime.
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: [archive] command line

To get the absolute command line, you will have to use the Windows API. The function you are seeking is GetCommandLine in kernel32.dll.

This one is a little bit tricky to use, as it makes use of dynamic memory. Fortunately, I have a demo program for this:

IDENTIFICATION DIVISION.
PROGRAM-ID. GetCmdLine.
DATE-WRITTEN. 2003/01/24
REMARKS.
*This program illustrates two issues. First of all it shows how to
*specificly access the entire commandline as it was provided when your
*application were started, including the runtime name.
*Aside of that, it also provides an example of how to copy a null
*terminated ANSI string in which the length by characters are unknown
*to a cobol pic x variable.
* Copyright (c) 1996-2003 by Acucorp, Inc. Users of ACUCOBOL
* may freely modify and redistribute this program.

WORKING-STORAGE SECTION.
77 lpString PIC 9(9) COMP-5.
77 SingleChar PIC X.
77 StringBuffer PIC X(1024).
77 StrCounter PIC 9(04).

PROCEDURE DIVISION.
MAIN-LOGIC.
*We're calling the API, make sure we use the correct calling
*convention
SET ENVIRONMENT "DLL-CONVENTION" TO "1".
*The function we are about to use, are located in kernel32.dll
CALL "KERNEL32.DLL".
*Call the function to get the command line, note the case sensitivity
*and also the 'A', indicating that we are calling the ANSI version of
*the function. The function has no parameters, thus no USING, but it
*returns the value we want, thus the use of GIVING.
CALL "GetCommandLineA" GIVING lpString.

INITIALIZE SingleChar
StringBuffer.
MOVE 1 TO StrCounter.
*NULL terminated strings use character code 0 to indicate end of
*string, let us perform until we reach that character. However,
*as we haven't yet got the first character, we use the term
*WITH TEST AFTER.
PERFORM WITH TEST AFTER UNTIL SingleChar = LOW-VALUE
*Copy the character located at the memory address that lpString
*is pointing at to our variable SingleChar.
CALL "C$MEMCPY" USING
BY REFERENCE SingleChar | Target address
BY VALUE lpString | Source address
BY VALUE 1 | Copy 1 byte
END-CALL
ADD 1 TO lpString | Increment to next char
*If we are not at the end of the string, add the character to our
*buffer.
IF SingleChar NOT = LOW-VALUES
STRING SingleChar DELIMITED BY SIZE
INTO StringBuffer WITH
POINTER StrCounter
END-STRING
END-IF
END-PERFORM.
*We do this INSPECT only because it helps keeping the message dialog
*small. If we don't the dialog will be huge as this is a pic x(1024)
INSPECT StringBuffer REPLACING TRAILING
SPACES BY LOW-VALUES.
DISPLAY MESSAGE BOX
StringBuffer
TITLE "GetCommandLine Example".
CANCEL "KERNEL32.DLL".
GOBACK.
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: [archive] command line

It is exactly what i was searching for!
0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.