Invoke Methods

Topics

Topic

Detail

See also

Access

On the Workbench window, right-click on the instance on which to execute a method, and select the Invoke context menu option.

 

Choose Method

A list of methods for the type are presented in a dialog; select a method from the list and click on the Invoke button.

Note that all methods listed are public; private methods are not available.
 

debug_work_methods

 

 

Supply Arguments

In the example, the instance or variable Rob has been created, of type MyClassLibrary.CRobert, and the method AddFriends invoked that takes an array of CPerson objects as its only argument.

You now supply to it three other Workbench instances: Fred, John and William.
 

debug_work_invoke_with_vars

 
 

 

Arguments

In the dialog above, type any parameters required by the constructor:

Literals as arguments
 
Text:      abc or "abc" or "a b c"
Numbers:    1 or 1.5
 
Objects as arguments
 
If an argument is not a literal then you can supply it in the list only if you have already created an instance of that type in the workbench; you do this by typing the name of the instance as the argument.
 
The debugger checks any name entered in an argument against its list of workbench instances, and substitutes that instance in the actual call to the method.
 
Strings as arguments
 

 Surrounding strings with quotes is unnecessary as anything you type for a string argument becomes the value of the string; for example, the only time you should surround strings with quotes is in supplying elements of a string array, or where the string is equal to the name of an existing workbench instance.
 

         "A b c"

         "a b $ % 6 4"

         A b c d

         As 5 7 ) 2 === 4
 

Arrays as arguments
 

 Enter the elements that compose the array, separated by commas:

         Type                Arguments

         String(  )        one,two,three,"a book","a bigger book"

         CPerson(  )        Tom,Dick,Harry

 

If you enter text that matches the name of an existing instance, surround it in quotes to avoid the debugger passing the instance rather than a string.

debug_work_invoke
 

 

Invoke

Having chosen the constructor and supplied any arguments, click on the Invoke button to create the variable.

Output confirming this action is displayed in the Debug window.

 

Run the Debugger

Learning Center topics

(Alt+F1) | Enterprise Architect | Execution Analysis | Object Workbench | Invoke Methods