2.2.4.32.10 OriginObject::DoMethod


Description

Execute object LabTalk methods

Syntax

int DoMethod( LPCSTR lpcszCmd, DWORD dwCntrl = 0, double * pdVal = NULL )
int DoMethod( LPCSTR lpcszCmd, LPCSTR lpcszArg, double * pdVal = NULL);
int DoMethod( LPCSTR lpcszCmd, LPCSTR lpcszArg, string & strReturn);

Parameters

lpcszCmd
[input] Object method name, case insensitive
dwCntrl
[input] method's input if require
pdVal
[output] return value, if index variable type, 1 offset, like Labtalk
lpcszCmd
[input] Object method name, case insensitive
lpcszArg
[input] method's input if require
strReturn
[output] return value, if index variable type, 1 offset, like Labtalk
lpcszCmd
[input] Object method name, case insensitive
lpcszArg
[input] method's input if require
pdVal
[output] return string value

Return

Returns 1 if lpcszCmd is a valid method and 0 if it is not. -1 if error occurs If pdVal is NULL will return the method return integer value directly

Examples

EX1

void DoMethod_ex1(string strSheetName)
{
	Page pg = Project.Pages();
	double dRet;
	int nRet = pg.DoMethod("layerNumber", strSheetName, &dRet);
	int nRet2 = pg.DoMethod("layerNumber", strSheetName);
}

EX2

void DoMethod_ex2()
{
	Worksheet wks = Project.ActiveLayer();
	int nn = wks.DoMethod("dc.Allow", 1);
	out_int("wks.dc.Allow(1) = ", nn);
}

EX3

void cpdc()
{
	WorksheetPage wp = Project.Pages();
	wp.DoMethod("cp.add", "1 40 DataConnector 3");// show Control Pane
	GETN_BOX(trTemp)
	GETN_NUM(xFrom, "X From", 1.3)
	GETN_NUM(xStep, "X Step", -0.5)
	string strxml = trTemp.XML;
	wp.DoMethod("cp.SetTree", strxml);
}

EX4

//DoMethod is implemented for Column class in 9.8b
void DoMethod_col()
{
	Worksheet wks = Project.ActiveLayer();
	Column cc(wks, 1);
	LT_set_str("%Z", "A+1");
	cc.DoMethod("SetFormula", "Z, 1");
}

EX5

//add "NextName" to get next object name in v2022:
void abb(string str1="abc")
{
	Layer ly = Project.ActiveLayer();
	string strNew;
	ly.DoMethod("NextName", str1, strNew);
	out_str(strNew);

EX6

void	test_DoMethod_String()
{
	string strReturn;
	Worksheet wks = Project.ActiveLayer();
	int	nRet = wks.DoMethod("Cell", "2, 2", strReturn);
	out_str(strReturn);
}

Remark

See Also

OriginObject::SetProp
LT_evaluate
Layer::LT_execute

Header to Included

origin.h