Having a BASIC program launch another program 
Author Message
 Having a BASIC program launch another program

I need to write a small front-end type of program for one of my
applications.  Would I be able to write something in BASIC that would
work this way (take my input and run the other program with those
options)?  If so, what are some commands I should use? Thanks!

--
Zach Babayco





Tue, 26 Jan 1999 03:00:00 GMT  
 Having a BASIC program launch another program

For a DOS-style menu, ala QBASIC:

DO
  CLS ' Clear screen
  PRINT "1. Start PROG with -A" ' Print menu
  PRINT "2. Start PROG with -B"
  PRINT "3. Start ABCDE with -A"
  PRINT "4. Start ABCDE with -B"
  PRINT "5. Quit"
  PRINT
  PRINT "Enter the letter of your choice: "; ' Prompt
  GOSUB DoInput
LOOP UNTIL quit > 0
END ' SYSTEM might be better

ActOnInput:
DO: i$ = INKEY$: LOOP UNTIL i$ <> "" ' Wait for key input
PRINT i$ ' Print input key
IF i$ = "1" THEN
  SHELL "C:\PROG\PROG.EXE -A" ' Execute appropriate command
ELSEIF i$ = "2" THEN
  SHELL "C:\PROG\PROG.EXE -B"
ELSEIF i$ = "3" THEN
  SHELL "C:\ABCDE -A"
ELSEIF i$ = "4" THEN
  SHELL "C:\ABCDE -B"
ELSEIF i$ = "5" THEN
  quit = 1 ' Quit the menu
END IF
RETURN

Good luck!

Brent P. Newhall
------------------------------------------------------------------
"Our greatest weakness lies in giving up.  The most certain way to
succeed is always to try just one more time." -- Thomas A. Edison



Tue, 26 Jan 1999 03:00:00 GMT  
 Having a BASIC program launch another program


Uhmm ... if you don't mind my breaking in, what can you do if you get an
insufficient memory error message? Like SHELL-ing doesn't exactly give you a
whole lot of memory to run programs with ...

B. Leung
~~~~~~~~~~
If everyone's on the bandwagon, who's going to pull?
The only way to go from there is downhill.



Tue, 26 Jan 1999 03:00:00 GMT  
 Having a BASIC program launch another program

From: Tomas Tornevall (2:200/213)

 > For a DOS-style menu, ala QBASIC:

 > DO
 >   CLS ' Clear screen
 >   PRINT "1. Start PROG with -A" ' Print menu
 >   PRINT "2. Start PROG with -B"
 >   PRINT "3. Start ABCDE with -A"
 >   PRINT "4. Start ABCDE with -B"
 >   PRINT "5. Quit"
 >   PRINT
 >   PRINT "Enter the letter of your choice: "; ' Prompt
 >   GOSUB DoInput
 > LOOP UNTIL quit > 0

Here's a better one:

================================================================
CLS
RestartMenu:
DO
  LOCATE 1, 1
  PRINT "1. Start PROG with -A" ' Print menu
  PRINT "2. Start PROG with -B"
  PRINT "3. Start ABCDE with -A"
  PRINT "4. Start ABCDE with -B"
  PRINT "5. Quit"
  PRINT
  PRINT "Enter the letter of your choice: "; ' Prompt
PressKey = VAL(INKEY$)
LOOP WHILE PressKey = 0

IF PressKey = 1 THEN SHELL "C:\PROG\PROG.EXE -A" ' Execute appropriate command
IF PressKey = 2 THEN SHELL "C:\PROG\PROG.EXE -B"
IF PressKey = 3 THEN SHELL "C:\ABCDE -A"
IF PressKey = 4 THEN SHELL "C:\ABCDE -B"
IF PressKey = 5 THEN END ' SYSTEM might be better
CLS
GOTO RestartMenu
================================================================

//Tomas Tornevall

 * Origin: FreeWare Data/2 (2:200/213)



Wed, 27 Jan 1999 03:00:00 GMT  
 Having a BASIC program launch another program

AR>Uhmm ... if you don't mind my breaking in, what can you do if you get an
AR>insufficient memory error message? Like SHELL-ing doesn't exactly give you a
AR>whole lot of memory to run programs with ...

Get some EMS or XMS source and dump a bunch of your data in there. Or
find a utility on the net called "SHROOM" (Shell room utility) it will
force any program to swap memory when needed.



Wed, 27 Jan 1999 03:00:00 GMT  
 Having a BASIC program launch another program

Quote:


> Uhmm ... if you don't mind my breaking in, what can you do if you get
> an insufficient memory error message? Like SHELL-ing doesn't exactly
> give you a whole lot of memory to run programs with ...

> B. Leung
> ~~~~~~~~~~

One way to do it would be to call your Basic menu program from a batch
file.  Make you rselection within the Basic program, but instead of
shelling to the program chosen , have the menu program set the DOS
ERRORLEVEL depending on the choice made.  Then have the batch program
run the program selected depending on the value of the ERRORLEVEL.  
This way the Basic program has already exited and is not taking up
space in memory.

Now if I could only remember how to set the ERRORLEVEL from Basic...

Well... in refreshing my memory, I guess I must have used the
SetLevel command in QuickPak Professional.  Not sure if you can set
the DOS ERRORLEVEL in plain QuickBasic?



Thu, 28 Jan 1999 03:00:00 GMT  
 Having a BASIC program launch another program

Quote:



> > Uhmm ... if you don't mind my breaking in, what can you do if you get
> > an insufficient memory error message? Like SHELL-ing doesn't exactly
> > give you a whole lot of memory to run programs with ...

> > B. Leung
> > ~~~~~~~~~~

> One way to do it would be to call your Basic menu program from a batch
> file.  Make you rselection within the Basic program, but instead of
> shelling to the program chosen , have the menu program set the DOS
> ERRORLEVEL depending on the choice made.  Then have the batch program
> run the program selected depending on the value of the ERRORLEVEL.
> This way the Basic program has already exited and is not taking up
> space in memory.

> Now if I could only remember how to set the ERRORLEVEL from Basic...

> Well... in refreshing my memory, I guess I must have used the
> SetLevel command in QuickPak Professional.  Not sure if you can set
> the DOS ERRORLEVEL in plain QuickBasic?

OK, found another way to set ERRORLEVEL.

See the Basic Archives FAQ at http://www.fys.ruu.nl/~bergmann/basic.html

Haven't actually tried this method out yet though.



Fri, 29 Jan 1999 03:00:00 GMT  
 Having a BASIC program launch another program

Quote:



> > Uhmm ... if you don't mind my breaking in, what can you do if you get
> > an insufficient memory error message? Like SHELL-ing doesn't exactly
> > give you a whole lot of memory to run programs with ...

> > B. Leung
> > ~~~~~~~~~~
> One way to do it would be to call your Basic menu program from a batch
> file.  Make you rselection within the Basic program, but instead of
> shelling to the program chosen , have the menu program set the DOS
> ERRORLEVEL depending on the choice made.  Then have the batch program
> run the program selected depending on the value of the ERRORLEVEL.  
> This way the Basic program has already exited and is not taking up
> space in memory.
> Now if I could only remember how to set the ERRORLEVEL from Basic...
> Well... in refreshing my memory, I guess I must have used the
> SetLevel command in QuickPak Professional.  Not sure if you can set
> the DOS ERRORLEVEL in plain QuickBasic?

You can do it in PDS with the END statement, but it will require some
interrupt calls in QB. I don't have the QB version handy, since I use
PDS, but it _will_ work, although you can't use it in the IDE.

Check around, I've seen the code here and there before.

- Len Philpot ------------------------------


web page:  http://www2.linknet.net/lphilpot/




Sat, 30 Jan 1999 03:00:00 GMT  
 Having a BASIC program launch another program

Quote:


> Uhmm ... if you don't mind my breaking in, what can you do if you get an
> insufficient memory error message? Like SHELL-ing doesn't exactly give you a
> whole lot of memory to run programs with ...

You can get around that with batch files:

MENU.BAT:

  \dos\qbasic /run \menu.bas
  call \menurun.bat

MENU.BAS:
  cls
  print "1. Prog -a"
  print "2. Prog -b"
  print "3. abc -a"
  print "4. abc -b"
  print "5. Quit"
  a$=""
  do while val(a$)<1 or val(a$)>5
    a$=input$(1)
  loop
  select case val(a$)
    case 1
      b$="\prog\prog.exe -a"
    case 2
      b$="\prog\prog.exe -b"
    case 3
      b$="\abc\abc.exe -a"
    case 4
      b$="\abc\abc.exe -b"
    case 5
      b$="echo Exiting..."
  end select
  open "c:\menurun.bat" for output as #1

  close #1
  system

This way, QBasic, and the menu program are unloaded from memory before
the other program is run.

Hope this helps,
Charles Clancy



Wed, 03 Feb 1999 03:00:00 GMT  
 Having a BASIC program launch another program

Quote:

>I need to write a small front-end type of program for one of my
>applications.  Would I be able to write something in BASIC that would
>work this way (take my input and run the other program with those
>options)?  If so, what are some commands I should use? Thanks!

Wite a Batch File (START.BAT)

------------------START.BAT------------------------
:START
MENU
GOTO START
---------------------------------------------------------------

Wite your menu program (described in messages elsewhere)
but instead of SHELL (yech!) try using the CHAIN command
or the RUN Command. Both will EXIT your program, and run
the one you choose. When they're exited, the batch file will
take back over and return you to the menu.

I wrote a BBS DoorGame with 17 smaller doors inside of
it (DoorMania) and I used the RUN command to keep
passing control from door-to-door.




Thu, 04 Feb 1999 03:00:00 GMT  
 
 [ 10 post ] 

 Relevant Pages 

1. Launching Windows Program from DOS Program

2. How to launch a VB program off the back of a non VB program

3. Registry read Failure when program launched by AT scheduling program

4. dbase programming(basic) in relation to Visual Basic programming

5. Using Word from a Visual Basic program launched from the web

6. Launching external programs from Visual Basic

7. Launching MS-DOS from with in a Visual Basic Program

8. (2nd Post) BASIC programming advice needed: PKWARE'S compression utilities front end application - PROGRAMMING PROJECT

9. Chapter 24 of Visual Basic RPG programming tutorial online - Programming random quests

10. Chapter 23 of Visual Basic RPG programming tutorial online - Programming random quests

11. How To Run Another Program From Visual Basic Program

12. Managing other programs from a Visual Basic Program

 

 
Powered by phpBB® Forum Software