APGen Documentation Previous Topic: ScriptArguments.Add() Next Topic: ScriptArguments.Remove() Parent Topic: ScriptArguments Object    ScriptArguments Object
ScriptArguments.FindString()
See Also:

The ScriptArguments.FindString() method searches for a string argument containing a substring.

Syntax

VBScript:

nIndex = oArguments.FindString( sSubString [, nStartIndex ] )

JScript:

nIndex = oArguments.FindString( sSubString [, nStartIndex ] );

Object

oArguments A ScriptArguments object.

Parameters

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.

Return Value

nIndex The index of an argument that contains sSubString.  If no argument is found containing sSubString, -1 is returned.

Notes

FindString() is useful for searching for command-line switches and labeled arguments.

Example

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

Applies To

ScriptArguments Object