Programming Guide


Calls a method of a service component, Java object or COM control

char *sm_obj_call(char *method_spec);

A string specifying the method and its parameters consisting of the following:

An integer handle identifying the component whose method you want to call. Object handles are returned by sm_obj_create for component objects, sm_prop_id for ActiveX controls and by sm_obj_call.

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

p1, p2, ...
(Optional) A comma-delimited list of the method's parameters. Unused parameters can be omitted, as in:
sm_obj_call ("TreeView, \"Add\" , , , , 'First node'")


COM, EJB, Java





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 COM component, use the Panther AxView utility, or use the ViewComponent Interface in the Panther Editor for service components.

This function returns a string; the component itself can return different types of data.

Java Objects

For calling methods of Java objects, the method name can include an optional type-specifier to eliminate ambiguity for overloaded methods (see Working with Java Objects for further information on using type-specifiers.) @obj() may be used to pass in Java objects as parameters for the Java method. For primitive and String valued method return types, this function returns the value as a string. Otherwise, a Panther object ID is returned. This object ID should be passed to sm_obj_delete_id when the associated Java object is no longer needed in order to allow for garbage collection by the JVM.

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 of sm_obj_call is different in JPL from that in 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.


// 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
id = sm_obj_create("cCustomers")
proc GetCustomer
call sm_obj_call(id, "GetCustomer", \
CompanyName, CustomerID, Phone)
// This JPL procedure closes down Microsoft Excel
// that is running as a COM component.

proc close
call sm_obj_call(ExcelID, "Application.Quit")

See Also

sm_obj_get_property, sm_obj_set_property