mirror of
https://github.com/opsxcq/mirror-textfiles.com.git
synced 2025-08-07 09:56:55 +02:00
71 lines
2.4 KiB
Plaintext
71 lines
2.4 KiB
Plaintext
|
||
Ä Area: BATPOWER ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
|
||
Msg#: 7 Date: 16 Sep 95 16:17:00
|
||
From: Tony Baechler
|
||
To: Larry Kwiatkowski
|
||
Subj: Re: Why Doesn't the following work?
|
||
ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
|
||
|
||
Note: This is not a very good explanation, I leave it to the experts to
|
||
explain better.
|
||
-Quoting Larry Kwiatkowski to Tony Baechler, (13 Sep 95 13:54:00).
|
||
|
||
LK> Yes, indeed, Tony - I have a tough time with the IF statements in
|
||
LK> batch- files. Could you expand a bit on the use of IF ..... ELSE IF
|
||
|
||
I am not wonderful with that command myself, but if, for example, you
|
||
wanted to check for a file's existance, you might use:
|
||
IF EXIST FILENAME REM
|
||
IF NOT EXIST FILENAME REM
|
||
|
||
IF EXIST FILENAME basically says, "If this file is found, then ..." I put
|
||
REM where you would put the "then" part of the statement. For example,
|
||
you might use this:
|
||
|
||
IF EXIST \AUTOEXEC.BAT ECHO Found it.
|
||
|
||
Likewise, if not exist says, "If this file is NOT found then ..." You
|
||
might use the following.
|
||
|
||
IF NOT EXIST \DV\DV.COM ECHO DesqView missing.
|
||
|
||
Another little trick is to use this to check for a directory which might
|
||
be empty.
|
||
|
||
IF EXIST \DV\NUL ECHO DV directory found.
|
||
IF NOT EXIST \DV\NUL ECHO The DV directory is missing.
|
||
|
||
Another form of the IF command can be best described with a little BASIC
|
||
example.
|
||
|
||
1 IF A$= "TEST" THEN GOTO 3
|
||
|
||
The batch equivalent would be:
|
||
|
||
IF %A$ "TEST" GOTO TEST
|
||
|
||
There is no "then" statement in if commands with batch files. There is
|
||
also no line numbers.
|
||
|
||
If you want to write a batch file to check for command line parameters,
|
||
you might write a little batch like this.
|
||
|
||
@ECHO OFF
|
||
IF "%1" == "" GOTO NOPARM
|
||
ECHO %1
|
||
GOTO END
|
||
:NOPARM
|
||
ECHO No command line parameters.
|
||
:END
|
||
|
||
"%1" is the first parameter passed to a batch file on the command line, %2
|
||
is the second, etc. BASIC uses COMMAND$ for this and makes you separate
|
||
each part yourself. Batch splits each parameter (I.E. each thing ending
|
||
in a space) into a different variable.
|
||
|
||
Note: I am saving this message, if any one wants to use or repost this,
|
||
that is fine.
|
||
Fido: 1:202/1207.4, Email: baechler@cts.com, ftp://ftp.europa.com
|
||
//outgoing/baechler, www: ftp://ftp.europa.com//outgoing/baechler<65>Â
|
||
... Top Secret Message: Please Read, Print, and Eat.
|