How Do I Dynamically Call a Program Within Another Application Not Defined as a Component? (Magic xpa 2.x)
While components are easy to use, you can call programs in another application without using components. There are several ways to do this, including implementing your called programs as COM objects or SOAP services. But the two most direct methods are using a Call Remote, or Call by Name.
Note that when you use these types of calls, the Magic xpa Studio has no information about the object you are calling until runtime, so it is up to you to code the name and arguments correctly.
-
First, set up a Service that points to the other application. That is done in Options->Settings->Services. Zoom from the Endpoint column to select the application you want to use.
-
Next, code your Call Remote operation.
-
Open up a line by pressing F4.
-
Type C for Call.
-
Type R for Remote.
-
Go to the Operation Properties to enter the rest of the operation (Alt+Enter, or click on the Properties pane if it is open).
-
From the Service field, zoom to select the service that points to the application you want.
-
Type in the Program name. This should be the public name of the program within the application you are calling. It is up to you to type it correctly.
-
Zoom from the Arguments field to enter whatever arguments the program requires. Again, it is up to you to set them correctly, there is no automatic match-up as there is with a component.
Now, when the program runs, it will call the program from the other application.
-
Enter the Call By Name operation:
-
Open up a line by pressing F4.
-
Type C for Call.
-
Type N for by Name.
-
Go to the Operation Properties (Alt+Enter, or click on the Properties pane if it is open).
-
Zoom from the Public program name to get to Expression rules. Type in the public name of the program you want to call.
-
Zoom from the Cabinet file name field to enter the name of the cabinet file that has the program.
-
Zoom from the Arguments field to enter the arguments you want to send and receive from this program.
That’s all there is to it. The program will be called from the cabinet file you specified.
Hint: Although we show the path name typed in for clarity, it would be better to use a variable in the Main Program to hold the path name for all the components being used, and to use Logical Names.