home *** CD-ROM | disk | FTP | other *** search
- «MDRV»«MDNM»STRINGS
-
-
- Douglas Boling September 10, 1991 (Utilities)
-
- To enable batch files to manipulate strings, request and interpret
- user input, process files, return system information, and perform simple math
- by adding functions to the batch file language. Stores information in either
- the local or the master environment.
-
- Format: STRINGS [/?][/M][/Pc][environment var =] FUNCTION
- [str1][, str2][, str3]
-
- Remarks: Entered with the /? switch, STRINGS presents a multi-screen help
- list of its FUNCTION calls and their user-supplied parameters (str1, str2,
- str3), which is printed overside. By default, STRINGS uses the local
- environment (as do batch files) to store user-named environment variables; the
- /M switch places these in the master environment, where they can be accessed
- by multiple DOS sessions under Windows. The /M switch is also useful for
- preserving variable assignments made when shelled out from an application, for
- the default local environment is lost when you exit from DOS back into the
- running program.
-
- The parse character, used to separate parameter strings, can be
- changed from the default comma to any unused character c, by specifying the
- /Pc switch. Leading spaces before a parameter string are normally ignored;
- they can be preserved by doubling the parse character (which is not printed)
- immediately before the beginning of the parameter.
-
- To illustrate the syntax, using one of the functions listed overside,
- if executed from within a .BAT file, the command
-
- STRINGS /M XYZ = MID This is a sample string, 11, 6
-
- would store the word sample (which starts with the 11th character in
- the parameter string and itself occupies 6 characters) under the variable name
- XYZ in the master environment. STRINGS could later be used to retrieve this
- value by using the MASTERENV function and specifying XYZ as its parameter.
-
- A null string is returned if 0 characters are specified when using the
- LEFT or RIGHT functions, or if a starting character larger than the string
- length is requested when using the MID function. Assigning a null string to a
- variable erases that variable name from the environment.
-
- ERRORLEVEL 1 codes are returned by attempting to READ line 0 or a line
- number greater than contained in the specified file, and by attempting to
- WRITE (append a line to) a read-only file. The SUB (subtract) function also
- returns an ERRORLEVEL 1 code when the result is a negative number; this can be
- used by a batch file to implement a compare function.
-
- The table below lists the functions supported by STRINGS, together
- with the parameters to be supplied. A fuller account of each of these is
- printed in the original article.
-
- Function Description Parameters to Supply
-
- LEFT Returns left n chars String, No. chars
- RIGHT Returns right n chars String, No. chars
- MID Returns middle n chars String, Start char, Len.
- LENGTH Returns string length String
- FIND Finds position of findstring String, findstring
- FINDC Case sensitive FIND String, findstring
- LOWER Returns string all lowercase String
- UPPER Returns string all uppercase String
- CHAR Returns ASCII no. of char Character
- VAL Returns ASCII char of no. Number
- READ Returns a line from a file Filename, line number
- WRITE Writes string to end of file Filename, String
- FILESIZE Returns file size Filename
- LINESIZE Returns no. of lines Filename
- FILENAME Returns filename Filespec
- FILEEXT Returns file extension Filespec
- TRUENAME Returns qualified filename Filename
- ASK Returns user response [Prompt string]
- ADD Returns the sum of two nos. Number, Number
- SUB Returns difference of two nos.Number, Number
- MUL Returns product of two nos. Number, Number
- DIV Returns quotient of two nos. Number, Number
- VER Returns the DOS version no.
- ENVFREE Returns the bytes free in the environment
- ENVSIZE Returns the size of the environment
- MASTERVAR Returns a variable from the Master env.