Public Function GetOpt( _ ByRef rOutArg As String _ , ByRef rInCmd As String _ , ByVal vInOpts As String _ ) As String
Assuming Const strOpts = "d:cn" Dim strArg As String Dim strCmds As String strCmds = "-cd50 -- -SAMPLE.DAT" for example GetOpt(strArg, strCmds, strOpts) = "c" leaves strArg = "" strCmds = "-d50 -- -SAMPLE.DAT" also GetOpt(strArg, strCmds, strOpts) = "d" leaves strArg = "50" strCmds = "-- -SAMPLE.DAT" also GetOpt(strArg, strCmds, strOpts) = "" leaves strArg = "" strCmds = "-SAMPLE.DAT"See also:
GetToken Function GetVBToken Function GetOpt Function (UNIX)rOutArg: String to which the value of any string argument will be assigned. When this function parses an argument that has a string value, the string value will be assigned to rOutArg. For example, when parsing the argument "-d50", the value "50" would be assigned to rOutArg.
Note: Two hyphens (--) can be used to stop processing command line arguments. For example, with a rInCmd value of "-- -SAMPLE.DAT", this function will return an empty string (signifying that no command line arguments were found) and it will leave "-SAMPLE.DAT" assigned to rInCmd.
Note: Function returns a question-mark if the command line contains an unrecognized argument. Your function which calls GetOpt should probably generate an error in such cases, since GetOpt cannot know how to process the rest of the command line argument phrase containing the invalid argument--if the unknown argument is followed by anything but a space character, GetOpt assumes that those characters represent arguments (not the string value of some unknown string-type argument).
Note: Multiple arguments can be specified following a hyphen, as long as all but possibly the last are boolean/flag type arguments. Only the last argument within in a list can have a string value, because with string arguments, the rest of the word up to the following space are considered part of the argument's string value. For example, assuming a vInOpts of "d:c", the "c" and "d" options could be specified following the same hyphen as in "-cd50" as long as the "d" argument follows the "c" argument since it accepts a string value.
Copyright 1996-1999 Entisoft
Entisoft Tools is a trademark of Entisoft.