Programming Guide



sm_obj_call

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_create for component objects, sm_prop_id for ActiveX controls.

method
The name of the method. Periods are allowed as part of the method specification, as in:
Application.Quit

p1, 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'")

Environment

COM, EJB

Scope

Client

Returns

Description

sm_obj_call calls 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.

COM Components

For COM components, if the typelib cannot be used to determine the parameter's type, @obj can 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 under sm_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. @obj may be needed if any of the parameters must be passed as objects.

Syntax Changes in JPL, Java and C

The syntax for sm_obj_call is different in JPL than other languages like C and Java. For JPL, sm_obj_call can have multiple parameters. For Java and C, sm_obj_call accepts one parameter, a string, which Panther parses into multiple parameters. See the Examples section.

Examples

// 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")
return
proc 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

See Also

sm_obj_get_property, sm_obj_set_property