2.1.15.5 LT_set_str


Description

Set LabTalk string variable

Syntax

BOOL LT_set_str( LPCSTR lpcszVar, LPCSTR lpcszContent )

Parameters

lpcszVar
[input] Origin string variables, %A through %Z, as well as LabTalk Object string properties
lpcszContent
[input] string content to be copied to Origin string variable, can be NULL to empty a string

Return

Return TRUE if success, return FALSE if string variable is not correctly specified or string is too long.

Examples

EX1

void    LT_set_str_ex1()
{
    char    szBuffer[200];
    // Get the value of the string variable %L
    LT_get_str("%L", szBuffer, 200);
    
    // Display the value:
    out_str(szBuffer);
    
    // Now set it to a new value:
    LT_set_str("%L", "New string value!");
    // Get the value of the string variable %L
    LT_get_str("%L", szBuffer, 200);
    
    // Display the value:
    out_str(szBuffer);
}

EX2

//this example is to show that it's equal for LT_set_str that Origin string variable with "$" or not
void LT_set_str_ex2()
{
    bool bRet;
    bRet = LT_set_str("myStr$","Hello");
    bRet = LT_set_str("myStr","Bye-bye");
    
    char szBuffer[100];
    LT_get_str("myStr$", szBuffer, 100);            
    out_str("myStr$ = %s" + szBuffer);//output "myStr$ = Bye-bye"            
}

Remark

Sets the value of a LabTalk global string variable or a LabTalk object string property.

See Also

LT_get_str

Header to Include

origin.h

Reference