Using Named Arguments

You can use named arguments to reorder arguments and omit optional arguments. Or, use them as a means of identifying the arguments in your commands.

Note: If you use the syntax shown in the Help topic for any InfoConnect method, you must put your arguments in the same order as they appear in the syntax line.

A named argument consists of a token (Token) to identify an argument, followed by a colon (:) and an equal sign (=), and then the argument value:

Token:= ArgumentValue

(In the syntax statement, the token name is the same as the argument name.)

For example, the SearchText1 method takes four arguments. Using standard syntax, the String argument must always be given first. (The line continuation character, an underscore preceded by a space, is used to break up long lines of code.)

Using SearchText1 without named arguments
Copy Code
Dim sp As ScreenPoint
Set sp = ThisIbmScreen.SearchText1("USERID", 8, 1, _
 FindOption.FindOption_Forward)

 

Using tokens derived from the syntax line, you can modify this command to use named arguments and then reorder the arguments, so that the following command is equivalent to the one above:

Using SearchText1 with named arguments
Copy Code
Set sp = ThisIbmScreen.SearchText1(FindOption:=FindOption.FindOption_Forward, _
StartRow:=8, StartColumn:=1, Text:="USERID")

 

For user-defined procedures, the token name is the variable name you use when you define the procedure.

 

 


2015 Attachmate