Discussion:
A PB Command Prompt shell
(too old to reply)
Bill Hutchison
2003-11-03 03:49:06 UTC
Permalink
I have it in mind to create a command prompt application with some of
my dos utilities (LS, MATCH, PPM (paragraph match), and maybe
BACK2ZIP) built in. Does anyone know of a reason this wouldn't work?
I'd essentially duplicate the logic of the dos command prompt within
the program.

I just recently got the latest version of PBCC.

Thanks,
Bill Hutchison

PS: If anyone would like to try the original version of my utilities
which are written in CB86 plus Minnow Bear's library of functions,
they are shareware and I can send them to you. Executables
only.
Michael Mattias
2003-11-03 13:33:12 UTC
Permalink
Post by Bill Hutchison
I have it in mind to create a command prompt application with some of
my dos utilities (LS, MATCH, PPM (paragraph match), and maybe
BACK2ZIP) built in. Does anyone know of a reason this wouldn't work?
I'd essentially duplicate the logic of the dos command prompt within
the program.
I just recently got the latest version of PBCC.
If you mean something like...

DO
LINE INPUT "Enter Choice", UserChoice

SELECT CASE UserChoice
CASE "A"
programname = "foo.exe"
commandline = "/X 14"
CASE "B"
programname = "bar.exe"
commandline = "Zagnut"
CASE "C"
programname = "baz.exe"
commandline = ""
CASE "X"
EXIT DO
END SELECT
Shell Programmname & " " & commandline
LOOP

...No reason that won't work. Looks pretty reasonable to me.

MCM
Bill Hutchison
2003-11-14 05:05:41 UTC
Permalink
On Mon, 03 Nov 2003 13:33:12 GMT, "Michael Mattias"
Post by Michael Mattias
Post by Bill Hutchison
I have it in mind to create a command prompt application with some of
my dos utilities (LS, MATCH, PPM (paragraph match), and maybe
BACK2ZIP) built in. Does anyone know of a reason this wouldn't work?
I'd essentially duplicate the logic of the dos command prompt within
the program.
I just recently got the latest version of PBCC.
If you mean something like...
DO
LINE INPUT "Enter Choice", UserChoice
SELECT CASE UserChoice
CASE "A"
programname = "foo.exe"
commandline = "/X 14"
CASE "B"
programname = "bar.exe"
commandline = "Zagnut"
CASE "C"
programname = "baz.exe"
commandline = ""
CASE "X"
EXIT DO
END SELECT
Shell Programmname & " " & commandline
LOOP
...No reason that won't work. Looks pretty reasonable to me.
MCM
Thanks for responding, but I mean something more like

DO
LINE INPUT DriveLtr$ & DrivePath$ & ">", CommandLine$
IF Ucase$(CommandLine$)<>"EXIT" Then
Shell CommandLine$
ELSE
Exit Loop
END IF
LOOP

to begin with, adding tests for intrinsic commands later.
This evening I tried Winzip Command Line from my Windows 98 DOS prompt
and discovered that "This program cannot be run from DOS mode."
I'm thinking it probably would run from a PB Shell.
Michael Mattias
2003-11-14 11:49:38 UTC
Permalink
Post by Bill Hutchison
Thanks for responding, but I mean something more like
DO
LINE INPUT DriveLtr$ & DrivePath$ & ">", CommandLine$
IF Ucase$(CommandLine$)<>"EXIT" Then
Shell CommandLine$
ELSE
Exit Loop
END IF
LOOP
to begin with, adding tests for intrinsic commands later.
This evening I tried Winzip Command Line from my Windows 98 DOS prompt
and discovered that "This program cannot be run from DOS mode."
I'm thinking it probably would run from a PB Shell.
Probably would, because (undocumented) the PB/CC compiler translates "SHELL"
into the Windows call 'CreateProcess' which creates... a Windows process!. I
Never installed the WinZip command-line support addon (I have it here, just
never installed), so I can't try it.

MCM
John Larkin
2003-11-30 19:49:36 UTC
Permalink
On Fri, 14 Nov 2003 11:49:38 GMT, "Michael Mattias"
Post by Michael Mattias
Post by Bill Hutchison
Thanks for responding, but I mean something more like
DO
LINE INPUT DriveLtr$ & DrivePath$ & ">", CommandLine$
IF Ucase$(CommandLine$)<>"EXIT" Then
Shell CommandLine$
ELSE
Exit Loop
END IF
LOOP
to begin with, adding tests for intrinsic commands later.
This evening I tried Winzip Command Line from my Windows 98 DOS prompt
and discovered that "This program cannot be run from DOS mode."
I'm thinking it probably would run from a PB Shell.
Probably would, because (undocumented) the PB/CC compiler translates "SHELL"
into the Windows call 'CreateProcess' which creates... a Windows process!. I
Never installed the WinZip command-line support addon (I have it here, just
never installed), so I can't try it.
MCM
Which brings up a question I've recently had cause to ask: can a
PB/Dos program, running in a DOS box under Windows, initiate another
process? I'd like to kick off a Windows command-line app without
waiting for the 'shell' thing to finish.

John
Michael Mattias
2003-11-30 23:18:38 UTC
Permalink
Post by John Larkin
Which brings up a question I've recently had cause to ask: can a
PB/Dos program, running in a DOS box under Windows, initiate another
process? I'd like to kick off a Windows command-line app without
waiting for the 'shell' thing to finish.
Untested, but I know you can SHELL a Windows program from PB/DOS, so I would
think you could...

J = SHELL ("START " + windowsProgramname$)

"start" should return immediately, so I'll bet you could even ...

SHELL "Start " & WindowProgramName

.. and the delay would be minimal...

Sorry, I don't do enough with PB/DOS anymore to warrant trying to test this.
(I get lost in the IDE *real quick*).

MCM
Lance Edmonds
2003-12-06 05:35:35 UTC
Permalink
Hi John,

Firstly, you can always just SHELL to the EXE directly.

However, there are major differences between whether the target app
is a console or a GUI application, in terms of how they run.

If you SHELL to a 32-bit console app, then SHELL executes synchronous
-- ie, the DOS app is suspended until the 32-bit console app
terminates, just like shelling to a DOS app.

While the console app will run as a separate process, both apps share
the same console window, and therefore both are tracked by Windows as
the "owners" of the window. Therefore the window can only be closed
when both the console and the DOS app have been terminated.

However, if you SHELL to a 32-bit GUI app, then it is started as a
completely separate Process. In addition, the SHELL statement returns
virtually immediately too, hence a SHELL to a GUI is an asynchronous
operation.

Therefore if you want to asynchronously launch any other application
from a DOS app and have the new app run in a separate window, then all
you need a simple GUI application that, in turn, uses the asynchronous
SHELL function to launch the final [target] application.

If the final target is a console or DOS app, a new console is spawned
by Windows, otherwise it runs in the GUI subsystem. In all three
cases, it'll be a separate process to the DOS app.

In PowerBASIC for Windows, that launcher app looks like this:

#COMPILE EXE
FUNCTION PBMAIN
FUNCTION = SHELL(COMMAND$)
END FUNCTION

I hope this helps!
Post by John Larkin
Which brings up a question I've recently had cause to ask: can a
PB/Dos program, running in a DOS box under Windows, initiate another
process? I'd like to kick off a Windows command-line app without
waiting for the 'shell' thing to finish.
Lance
PowerBASIC Support

-------------------------------------------------------------------------
PowerBASIC, Inc. | 800-780-7707 Sales | "We put the Power in Basic!"
316 Mid Valley Center | 831-659-8000 Voice | http://www.powerbasic.com
Carmel, CA 93923 | 831-659-8008 Fax | mailto:***@powerbasic.com
Continue reading on narkive:
Search results for 'A PB Command Prompt shell' (Questions and Answers)
9
replies
What is a DOS Console?
started 2006-09-20 09:03:35 UTC
programming & design
Loading...