2.1.15.2 LT_execute


Description

Execute LabTalk script code.

Syntax

BOOL	LT_execute(LPCSTR lpcszLabTalkStr, int wCntrl = 0, int* pnErr = NULL, DWORD dwOptions = 0);

Parameters

lpcszLabTalkStr
[input] Pointer to a string containing the LabTalk script code to execute.
wCntrl
[input] Internal used only.
pnErr
[output] Detail Labtalk execution error, enumerate as
enum
{
	LTEXECUTE_ERROR_NONE						= 0,
	LTEXECUTE_ERROR_GENERAL,					/// 1, general error, use everywhere
	LTEXECUTE_ERROR_USER_ABORT,
};
dwOptions
[input] Internal used only.

Return

TRUE if success, FALSE if LabTalk execution leads to error

Examples

EX1

// This is a self contained sample program for the function LT_execute, 
// To run the program, enter the following command in the Script window:
//   LT_execute_ex1
// If it runs successfully, the following meassage will be printed:
//   LT_execute succeeded.
//
void LT_execute_ex1()
{
    char szLabTalkStr[200]; //storage for LT commands
    BOOL rc;
    
    Worksheet wks;
    wks.Create();
    Dataset myXDs(wks,0);
    Dataset myYDs(wks,1);
    
    //******* Create sample data *****************
    myXDs.SetSize(5);
    myYDs.SetSize(5);
    myXDs[0]=1;  myYDs[0]=1;
    myXDs[1]=2;  myYDs[1]=1;
    myXDs[2]=3;  myYDs[2]=2;
    myXDs[3]=4;  myYDs[3]=4;
    myXDs[4]=5;  myYDs[4]=9;
    //******** End of Sample Data Creation *******

    strcpy(szLabTalkStr,"Worksheet -s 2;"); // Select B(Y) column
    strcat(szLabTalkStr,"run.section(Plot,Scatter);"); // Plot the selected column
    strcat(szLabTalkStr,"run.section(LR,FitLinear);"); // Perform Fit Linear
    rc=LT_execute(szLabTalkStr); // Demonstrate LT_execute
    if(rc) printf("LT_execute succeeded.\n");
    else  printf("LT_execute failed.\n");
}

Remark

When using LT_execute() to run LabTalk command, if the LabTalk string to be executed contains extra quotation mark, you simply need to remove the quotation mark inside the LabTalk string to make it executable.

See Also

Header to Include

origin.h

Reference