![]() | ![]() | Programming Guide |
Calls a method of a service component or ActiveX control
char *sm_obj_call (char *method_spec);
method_spec- A string specifying the method and its parameters consisting of the following:
object_id- An integer handle identifying the component whose method you want to call. The handle is returned through
sm_obj_createfor component objects,sm_prop_idfor ActiveX controls.method- The name of the method. Periods are allowed as part of the method specification, as in:
Application.Quitp1, p2, ...- (Optional) A comma-delimited list of the method's parameters. Unused parameters are allowed to be omitted, as in:
sm_obj_call ("TreeView, \"Add\" , , , , 'First node'")
COM, EJB
Client
sm_obj_callcalls methods that are part of the component's interfaces. To find which methods are available, refer to the documentation supplied with the component, use the Panther AxView utility, or use the ViewComponent Interface in the editor for service components.
This function returns a string; the component itself can return different types of data.
For COM components, if the typelib cannot be used to determine the parameter's type,
@objcan be used to specify the object ID of the parameter. Generally, this syntax will not be necessary. For an example of its usage, see the example undersm_com_load_picture.If you get a "type mismatch" error, refer to the component documentation and check that all the parameters are of the correct type.
@objmay be needed if any of the parameters must be passed as objects.
The syntax for
sm_obj_callis different in JPL than other languages like C and Java. For JPL,sm_obj_callcan have multiple parameters. For Java and C,sm_obj_callaccepts one parameter, a string, which Panther parses into multiple parameters. See the Examples section.
// This C function calls the InsertNode method of the
// ActiveX treeview control.
char *parent;
char *child;
child = sm_obj_call( "treeview->id, \"InsertNode\", parent, \"Child node\"");// This Java example calls the SetStyle method.
import com.prolifics.jni.*;
public class SetStyleButton extends ButtonHandlerAdapter
{
public int buttonValidate(FieldInterface f, int item, int context)
{
ScreenInterface scrn = f.getScreen();
WidgetInterface w = scrn.getWidget("tree");
CFunctionsInterface cfi = w.getCFunctions();String s = cfi.sm_obj_call("tree->id, \"SetStyle\", 1, 1, 1, 1");
return 0;
}
}// This is the JPL call for this method. Single quotation
// marks are used surrounding the method in order to pass
// double quotation marks to the method itself.
vars parent
vars child
child = sm_obj_call \
( treeview->id, "InsertNode", :parent, "Child node")// These JPL procedures instantiate the cCustomers COM
// component and call its GetCustomer method.
vars id
proc entry
@app->current_component_system=PV_SERVER_COM
id = sm_obj_create("cCustomers")
returnproc GetCustomer
call sm_obj_call(id, "GetCustomer", \
CompanyName, CustomerID, Phone)
return// This JPL procedure closes down Microsoft Excel
// that is running as a COM component.
proc close
call sm_obj_call(ExcelID, "Application.Quit")
return
sm_obj_get_property, sm_obj_set_property
![]()
![]()
![]()
![]()