3.9.5 LabTalk Keywords

Keywords in String

The following keywords are defined for string processing in LabTalk:

LabTalk Keyword C Token ASCII Code Description
TAB \t 9 The tab character
CR \r 13 Carriage Return
LF \n 10 Line feed (also, new line)
CRLF \r \n 9, 13 CR followed by LF, typically used as line separator in DOS/Windows
QUOTE \" 34 Double-quote
SLIST System List separator (stored in OS Region settings)

Examples

This example shows how to use quotes inside a string in LabTalk

str$="expression=%(quote)col(1)=col(2)+1%(quote)";
str$=;// should print "expression="col(1)=col(2)+1""
int i = str.Find('"');
i=;//-->12
// same as '"' when used as a string function argument:
i=str.Find(quote, i+1); 
i=;//-->28
i=str.Count('"');
i=;//-->2
i=str.Count(quote);
i=;//--> also 2

Similar issues exist for new lines,

str$="line1%(CRLF)line2%(CRLF)line3";
type str$;
type "str has $(str.GetNumTokens(CRLF)) lines";
//should print:
//line1
//line2
//line3
//str has 3 lines

In this example, system List Separator is comma (",")

string str1="abc;efg,fjk";
int nn = str1.GetNumTokens(SLIST);
nn = ;
	
for(i=1;i<=nn;i++)
{
	string str$ = str1.GetToken(i, SLIST)$;
	type "$(i): %(str$)";
}
// should print
// nn=2
// 1: abc;efg
// 2: fjk