AT2k Design BBS Message Area
Casually read the BBS message area using an easy to use interface. Messages are categorized exactly like they are on the BBS. You may post new messages or reply to existing messages!

You are not logged in. Login here for full access privileges.

Previous Message | Next Message | Back to BAT Magic  <--  <--- Return to Home Page
   Local Database  BAT Magic   [186 / 250] RSS
 From   To   Subject   Date/Time 
Message   Visitor    ALL   MAIN.BAT   November 27, 1995
 1:25 PM *  

Title:      "Call Me Irresponsible, But Call Me Anyway"
Reference:  PC World September 1990
Author:     Steve Hardy
Files:      MAIN.DOC, MAIN.BAT

Calling batch files as subroutines can clutter a disk with many small
files, and it complicates error handling. It just seems irresponsible
of DOS not to let batch files call subroutines as you can do in
BASIC, Pascal, and C.

One way to do just that is illustrated by MAIN.BAT. First, the
program checks whether parameter %1 equals `proc', representing a
procedure call. If so, GOTO jumps to a label passed in parameter %2.
If %1 is not `proc', execution begins at label `:start'. After
displaying a message, three CALL commands execute the same batch
file, using %0 to obtain the file's path name. The CALL statements
pass parameters `proc' and `procN', where N is the number of a
procedure to call. Each procedure begins with a label (`:proc1', for
example) and ends with `GOTO end'. You can also pass other arguments
beginning with %3, as `:proc2' demonstrates by calling `proc3'.

As written, MAIN.BAT requires DOS 3.3 or later. Under DOS 3.2, change
`@echo' to echo, and replace `call' with c:\command /C, substituting
a:  for `c:' if you boot to a floppy.

To experiment with the idea, from DOS, type main with zero or more
parameters. You can also force the batch file to run only a selected
subroutine. For example, enter main proc proc2 to run the statements
under label `:proc2'.

@echo off
if "%1"=="proc" goto %2
echo main %1
call %0 proc proc1 %1
call %0 proc proc2 %1
call %0 proc proc4 %1
goto end
:proc1
echo proc1 %3
goto end
:proc2
echo proc2 %3
call %0 proc proc3 %3
goto end
:proc3
echo proc3 %3
goto end
:proc4
echo proc4 %3
:end

___ Blue Wave/QWK v2.12
  Show ANSI Codes | Hide BBCodes | Show Color Codes | Hide Encoding | Hide HTML Tags | Show Routing
Previous Message | Next Message | Back to BAT Magic  <--  <--- Return to Home Page

VADV-PHP
Execution Time: 0.0149 seconds

If you experience any problems with this website or need help, contact the webmaster.
VADV-PHP Copyright © 2002-2024 Steve Winn, Aspect Technologies. All Rights Reserved.
Virtual Advanced Copyright © 1995-1997 Roland De Graaf.
v2.1.241108