|
ScriptArguments Object |
|
See Also: |
The ScriptArguments.FindString() method searches for a string argument containing a substring.
VBScript:
JScript:
| oArguments | A ScriptArguments object. |
| sSubString | The substring to search for. If this substring is found in a string argument, the index of that argument is returned. |
| nStartIndex | Optional. Start the substring search at this item, and search to the end of the Arguments collection. The default value is 0. |
| nIndex | The index of an argument that contains sSubString. If no argument is found containing sSubString, -1 is returned. |
FindString() is useful for searching for command-line switches and labeled arguments.
This example uses Script.Arguments.FindString() to find "name=" arguments that are passed into the script. List_names.apg:
<%# @LANGUAGE=JScript #%>
<%#
Output.Filename = "names.txt";
var iName = 0;
while (true)
{
iName = Script.Arguments.FindString("name=", iName);
if (iName != -1)
{ // Add the name to the list
var sArg = new String(Script.Arguments(iName));
Output.Write(sArg.slice(5) + "\r\n");
}
else
break;
++iName;
}
#%>
If you type
List_names.apg name=Fred age=40 name=Wilma age=35 "name=The Flinstones"
at the command line, you'll produce this output file (names.txt):
Fred
Wilma
The Flinstones