Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Calling DOS functions from COBOL program

Status
Not open for further replies.

Badger155

Programmer
Dec 14, 2000
1
0
0
NL
Hi all.

Been a mainframe programmer forever, but recently started messing with PC COBOL, ancient RM compiler, dating back to my college days.

What I need to know, is it possible to perform a CALL to a dos utility, for instance DIR, or COPY or DEL, RENAME, basically any file handling utils. I need to know from within my program what files are available on disk, in a certain directory, for the user to open. On A-Series UNISYS, we've got a function "SCANDIR" with a bunch of parameters to determine what files there are. Maybe something like that available for PC?

The problem of dynamically changing a filename when creating it, is something I've sorted out, but now there might be several files that the user can choose between. And I need to list them.

Any help/"wild ideas" will be tried. I've fried my brains and tried just about any possible method I could think of.
 
In Micro Focus Cobol you do it as below. MF is similar to RM (I believe). So until an RM johnnie gets back to you you need to find RM's equivalent.
Good Luck

------------------------------------------
Working-Storage Section.

01 ws-reply pic 99 comp-x.
01 ws-function-35 pic 99 comp-x value 35.
01 ws-null.
05 filler pic 99 comp-x value 0.
05 filler pic x.

Procedure Division.

display "dir" upon command-line
call x"91" using ws-reply
ws-function-35
ws-null.
----------------------------------------
 
Ca-Realia 4.2 does this also. I could email you some live
working programs for clarity sake.

request from rickj@intrstar.net..

Thanks,
RASI
 
In RM COBOL, you can execute system commands like this:

CALL "SYSTEM" USING command-line [repaint-screen] [exit-code].

where:

Command-line is an alphanumeric item containing the command to be executed (trailing spaces are automatically removed before the statement is executed)

Repaint-screen is an optional one-byte parameter. A "Y" (or "y" in this field means that the screen will be repainted after the command is executed. "N" or "n" means that it will not be repainted.

Exit-code is an optional S9(4) BINARY parameter that will contain the exit code of the command you executed, if you should desire to do so. A zero in here would mean a success, anything else a failure, but exact non-zero values vary by command. Betty Scherber
Brainbench MVP for COBOL II
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top