home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Frostbyte's 1980s DOS Shareware Collection
/
floppyshareware.zip
/
floppyshareware
/
GLEN
/
IS.ZIP
/
IS.DOC
< prev
next >
Wrap
Text File
|
1990-01-10
|
8KB
|
215 lines
IS - Batch File Condition Utility
By Byte_Magic Software
Usage: IS "function1" condition "function2"
General:
IS is used in batch files to check the truth of a statement
regarding two supported functions. If the statment is true, IS returns
ERRORLEVEL 0. If the statement is false IS returns ERRORLEVEL 1.
Functions:
IS supports functions for literal strings, user input, system date
and time, file date, file time, file size, disk size, and disk free
space. Since this program runs from batch files, it must conform to the
way DOS interprets the command line. The double quotes around each
function are there to force DOS to accept the function as one entity
even if it contains embedded spaces or tab characters. If the function
in its entirety contains no spaces or tabs you can safely omit the
qoutes.
The syntax for the supported functions is explained below.
User Input: IS input[(prompt)] ...
The optional prompt will be displayed at the current cursor
position and IS will wait for the user to enter something. Input stops
when the user presses <enter>.
System Date: IS sysdate ...
System Time: IS systime ...
Two simple functions, sysdate and systime return the system date
and the system time. The system date has the format mm/dd/yy, and the
system time has the format hh:mm:ss.
File Date: IS filedate([d:][\path\]filename.ext) ...
File Time: IS filetime([d:][\path\]filename.ext) ...
The filedate and filetime functions search for the required file in
the current drive and directory, or the optionally specified drive and
path, and returns the date or the time of last modification. The date
has the format mm/dd/yy and the time has the format hh:mm.
File Size: IS filesize([d:][\path\]filename.ext) ...
The filesize function searches for the required file in the current
drive and directory or on the optionally specified drive and path and
returns the size of the file.
Disk Free: IS diskfree[(drive)]
Disk Size: IS disksize[(drive)]
The diskfree function returns the free space on the current drive
or on the optionally specified drive given on the command line. The
disksize returns the total size of either the current drive or the
optional drive specified on the command line.
Conditions:
IS accepts the conditions listed below:
IS condition Means
------------ ------------------------------
eq equal to
gt greater than
lt less than
le less than or equal to
ge greater than or equal to
neq not equal to
ngt not greater than
nlt not less than
nle not less than or equal to
nge not greater than or equal to
When comparing the strings which result from each function, as well
as the user input strings and literal strings, IS always converts
everything to lowercase before doing any comparisons. That means 'Y' is
equal to 'y' and 'PASSword' is equal to 'passWORD'. Also, strings are
compared from left to right and the comparison is over when a pair of
characters fails to match. That means 'abcx' is greater than 'abcdefg'
even though the last string is longer.
There are two exceptions to the way that IS compares the results of
the functions. When both strings are dates, IS converts them to YYMMDD
format before the comparison. Also, when both strings consist of only
numeric digits, IS converts the strings to numbers before the
comparison. If the conversions above were not done, the string
comparison would cause IS to report that 10/22/86 is greater than
05/22/88, and that 999 is greater than 1000.
Statements:
IS statements are made up of a function, a condition and another
function. The format of a statement is the same as for a question:
IS function1 condition function2
Some of the possible statements that can be used inside a batch
file are:
IS filesize(somefile.ext) gt diskfree(a)
IS systime gt 16:00
IS "input(Enter Your Password: )" eq %password%
IS "Mighty User" eq "input(Enter your first and last name: )"
IS sysdate gt filedate(audit.dat)
IS disksize(c) eq 21204992
If the answer to the statement is TRUE, IS returns ERRORLEVEL 0. If
the answer is FALSE, IS returns ERRORLEVEL 1. (0 is TRUE, 1 is FALSE).
Unsupported functions, errors in a function, and errors in a
condition also have unique ERRORLEVEL return codes. The error codes
are:
Bad or Unsupported Returns
------------------ -------------
function1 ERRORLEVEL 11
function2 ERRORLEVEL 12
condition ERRORLEVEL 13
Errors in functions might be attempts to get the filesize of a non-
existent file or free space on a non-existent drive, as well as
requests for functions that are not built into IS.
Batch File Logic:
The ERRORLEVEL returned by IS to the batch file can be checked with
the IF ERRORLEVEL command. The batch processor is peculiar about the
way it checks this ERRORLEVEL. . .
Batch file contains: "IF ERRORLEVEL 1"
DOS thinks it means: "IF ERRORLEVEL is greater than or equal to 1"
This causes a problem when checking on the answer returned by IS.
If you simply run IS and then check for falsity with 'IF ERRORLEVEL 1',
you will be misled by DOS in the event of an error in either function
or the condition. To be sure that you interpret IS's answer correctly,
you should check for a false statement with:
'IF ERRORLEVEL 1 IF NOT ERRORLEVEL 2 GOTO FALSE'
actions for true here
or
'IF ERRORLEVEL 2 GOTO ERROR' (ERRORLEVEL >= 2 ?)
'IF ERRORLEVEL 1 GOTO FALSE' (ERRORLEVEL >= 1 ?)
actions for true here
Check an IS statement for truth with:
'IF NOT ERRORLEVEL 1 GOTO TRUE'
actions for false here
or
'IF ERRORLEVEL 2 GOTO ERROR' (ERROORLEVEL >= 2 ?)
'IF NOT ERRORLEVEL 1 GOTO TRUE' (ERRORLEVEL < 1 ?)
actions for false here
The above examples assume there are labels ':TRUE' and ':FALSE' in
the batch file.
There is a demo batch file included with IS to show how the utility
might be used. Read it and you will have advanced control over the way
your batch files interact with their environment.