Determines whether non-string expressions are automatically converted when added to strings
SET CONVERT
set strconvert on
? "This string can add numerics and dates etc. " + 100.89 + " " + date()
set strconvert off
? "This string can add numerics and dates etc. " + str(100.89,6,2) + " " + etos(date())
Return from a list the expression at the specified position
CHOOSE
? choose(2,"One","Two","Three")
Two
open database southwind
select employeeid, hiredate,CHOOSE(MONTH(HireDate),'Winter','Winter', ;
'Spring','Spring','Spring','Summer','Summer','Summer','Autumn','Autumn',;
'Autumn','Winter') AS Quarter_Hired from employees
EMPLOYEEID HIREDATE QUARTER_HIRED
1 09/08/2011 Autumn
2 08/14/1992 Summer
3 09/08/2011 Autumn
4 05/03/1993 Spring
5 10/08/1993 Autumn
6 10/17/1993 Autumn
7 01/02/1994 Winter
8 03/05/1994 Spring
9 11/15/1994 Autumn
https://www.lianja.com/doc/index.php/CHOOSE()
Enables or disables the use of ‘\’ to escape characters
SET STRESCAPE
set strescape on
? ""
https://www.lianja.com/doc/index.php/SET_STRESCAPE
Numeric value of a control character
CTRL
abandon = ctrl('g')
https://www.lianja.com/doc/index.php/CTRL()
Return a string where certain characters or strings have been escaped out or removed
STR_ESCAPE
? str_escape("Grocer's apostrophe")
Grocer''s apostrophe
https://www.lianja.com/doc/index.php/STR_ESCAPE()
Evaluate an expression and return the result as a string
ETOS
? etos({03/29/2003})
03/29/2003
? etos({03/29/2003},5)
03/29
? etos(10 * 10)
100
? etos(0.45,3)
.45
? etos("Hello" + " " + "World")
Hello World
? etos("Hello" + " " + "World",5)
Hello
? etos(.F.)
F
https://www.lianja.com/doc/index.php/ETOS()
Evaluate an expression and return the result as a string
TOSTRING
? tostring({03/29/2003})
03/29/2003
? tostring({03/29/2003},5)
03/29
? tostring(10 * 10)
100
? tostring(0.45,3)
.45
? tostring("Hello" + " " + "World")
Hello World
? tostring("Hello" + " " + "World",5)
Hello
? tostring(.F.)
F
https://www.lianja.com/doc/index.php/TOSTRING()
Convert carriage returns
HARDCR
cFormat = hardcr(notepad)
https://www.lianja.com/doc/index.php/HARDCR()
Replicate characters
REPLICATE
? replicate("-", 20)
--------------------
https://www.lianja.com/doc/index.php/REPLICATE()
Indent a character string
STRIDENT
open database southwind
use example
strtofile(strindent(mtos(notes),1),"indented.txt")
https://www.lianja.com/doc/index.php/STRINDENT()
Wrap a string to a given line width
WORDWRAP
open database southwind
use customers
echo wordwrap(companyname,20,"
\n",.T.)
https://www.lianja.com/doc/index.php/WORDWRAP()
Check whether an expression is a character string
IS_STRING
cVAR = "Hello"
? is_string(cVAR)
.T.
? is_string("World")
.T.
? is_string(tostring(date()))
.T.
https://www.lianja.com/doc/index.php/IS_STRING()
Return a string with ‘C’ style picture formatting
SPRINTF
// When %s is specified, the corresponding argument is converted to
// character format (similar to specifying etos()).
// Widths correspond to the default values, e.g. numerics are 10
cVAR=sprintf('It is %s, %s to be more precise',year(date()),datetime())
echo cVAR
cVAR=sprintf('The value of pi is %s',pi())
echo cVAR
cVAR=sprintf('They cost %s per %s',$99,100)
echo cVAR
cVAR=sprintf('Logicals can be %s or %s',.T.,.F.)
echo cVAR
// Formatting characters can contain a width, which will left pad with spaces
cVAR=sprintf('Right-justify and pad left: %10s this','Like')
echo cVAR
// Left justify by placing a '-' directly following the '%' character
cVAR=sprintf('Left-justify and pad right: %-10s this','Like')
echo cVAR
// %d is for numerics
cVAR=sprintf('It is %d',year(date()))
echo cVAR
// %t and %T are for formating datetime data types.
cVAR=sprintf('It is %d, %t to be more precise',year(date()),datetime())
echo cVAR
cVAR=sprintf('It is %d, %T to be even more precise',year(date()),datetime())
echo cVAR
// %f is for floating point numerics
cVAR=sprintf('The value of pi is %f',pi())
echo cVAR
// Decimal places can also be specified for floating point numerics (%f)
cVAR=sprintf('The value of pi to two decimal places is %4.2f',pi())
echo cVAR
// %y is for formatting currency data types
cVAR=sprintf('They cost %y per %d',$99,100)
echo cVAR
cVAR=sprintf('They cost %y per %d',$99,1000)
echo cVAR
cVAR=sprintf('They cost %y per %d',$99,10000)
echo cVAR
//%l and %L are for formatting logical datatypes.
cVAR=sprintf('Logicals can be %l or %l',.T.,.F.)
echo cVAR
cVAR=sprintf('Logicals can also be %L or %L',.T.,.F.)
echo cVAR
It is 2009, 11/11/2009 11:41:51 AM to be more precise
The value of pi is 3.1415926
They cost $99.0000 per 100
Logicals can be True or False
Right-justify and pad left: Like this
Left-justify and pad right: Like this
It is 2009
It is 2009, 11/11/2009 11:41:51 AM to be more precise
It is 2009, Wednesday November 11 2009 11:41:51 to be even more precise
The value of pi is 3.141593
The value of pi to two decimal places is 3.14
They cost $99.0000 per 100
They cost $99.0000 per 1000
They cost $99.0000 per 10000
Logicals can be True or False
Logicals can also be Yes or No
https://www.lianja.com/doc/index.php/SPRINTF()
Display a string with ‘C’ style picture formatting
PRINTF
// When %s is specified, the corresponding argument is converted to
// character format (similar to specifying etos()).
// Widths correspond to the default values, e.g. numerics are 10
printf('It is %s, %s to be more precise\n',year(date()),datetime())
printf('The value of pi is %s\n',pi())
printf('They cost %s per %s\n',$99,100)
printf('Logicals can be %s or %s\n',.T.,.F.)
// Formatting sequences can contain a width, which will left pad with spaces
printf('Right-justify and pad left: %10s this\n','Like')
// Left justify by placing a '-' directly following the '%' character
printf('Left-justify and pad right: %-10s this\n','Like')
// %d is for numerics
printf('It is %d\n',year(date()))
// %t and %T are for formating datetime data types.
printf('It is %d, %t to be more precise\n',year(date()),datetime())
printf('It is %d, %T to be even more precise\n',year(date()),datetime())
// %f is for floating point numerics
printf('The value of pi is %f\n',pi())
// Decimal places can also be specified for floating point numerics (%f)
printf('The value of pi to two decimal places is %4.2f\n',pi())
// %y is for formatting currency data types
printf('They cost %y per %d\n',$99,100)
printf('They cost %y per %d\n',$99,1000)
printf('They cost %y per %d\n',$99,10000)
//%l and %L are for formatting logical datatypes.
printf('Logicals can be %l or %l\n',.T.,.F.)
printf('Logicals can also be %L or %L\n',.T.,.F.)
It is 2009, 11/11/2009 11:41:51 AM to be more precise
The value of pi is 3.1415926
They cost $99.0000 per 100
Logicals can be True or False
Right-justify and pad left: Like this
Left-justify and pad right: Like this
It is 2009
It is 2009, 11/11/2009 11:41:51 AM to be more precise
It is 2009, Wednesday November 11 2009 11:41:51 to be even more precise
The value of pi is 3.141593
The value of pi to two decimal places is 3.14
They cost $99.0000 per 100
They cost $99.0000 per 1000
They cost $99.0000 per 10000
Logicals can be True or False
Logicals can also be Yes or No
https://www.lianja.com/doc/index.php/PRINTF()
Test for an alphabetic character
ISALPHA
store "965.23" to value
// If alpha assign 0
if isalpha(m->value)
value = 0
else
// convert to numeric
value = val(m->value)
endif
https://www.lianja.com/doc/index.php/ISALPHA()
Check to see if the first character in a given character expression is a digit
ISDIGIT
? isdigit("9 Belmont Ave")
.T.
? isdigit("Nine Belmont Ave")
.F.
https://www.lianja.com/doc/index.php/ISDIGIT()
Formatting by using a picture string
TRANSFORM
total = 3001.23
? transform(total, "$$$$$9.99")
$3001.23
? transform((0x1a * 2),"@0")
0x00000034
https://www.lianja.com/doc/index.php/TRANSFORM()
Return a character expression in reverse character sequence
REVERSE
open database southwind
use customers
index on reverse(customerid) tag revcust
use
set explain on
select * from customers where customerid like '%K'
https://www.lianja.com/doc/index.php/REVERSE()
// When %s is specified, the corresponding argument is converted to
// character format (similar to specifying etos()).
// Widths correspond to the default values, e.g. numerics are 10
printf('It is %s, %s to be more precise\n',year(date()),datetime())
printf('The value of pi is %s\n',pi())
printf('They cost %s per %s\n',$99,100)
printf('Logicals can be %s or %s\n',.T.,.F.)
// Formatting sequences can contain a width, which will left pad with spaces
printf('Right-justify and pad left: %10s this\n','Like')
// Left justify by placing a '-' directly following the '%' character
printf('Left-justify and pad right: %-10s this\n','Like')
// %d is for numerics
printf('It is %d\n',year(date()))
// %t and %T are for formating datetime data types.
printf('It is %d, %t to be more precise\n',year(date()),datetime())
printf('It is %d, %T to be even more precise\n',year(date()),datetime())
// %f is for floating point numerics
printf('The value of pi is %f\n',pi())
// Decimal places can also be specified for floating point numerics (%f)
printf('The value of pi to two decimal places is %4.2f\n',pi())
// %y is for formatting currency data types
printf('They cost %y per %d\n',$99,100)
printf('They cost %y per %d\n',$99,1000)
printf('They cost %y per %d\n',$99,10000)
//%l and %L are for formatting logical datatypes.
printf('Logicals can be %l or %l\n',.T.,.F.)
printf('Logicals can also be %L or %L\n',.T.,.F.)
// When %s is specified, the corresponding argument is converted to
// character format (similar to specifying etos()).
// Widths correspond to the default values, e.g. numerics are 10
cVAR=sprintf('It is %s, %s to be more precise',year(date()),datetime())
echo cVAR
cVAR=sprintf('The value of pi is %s',pi())
echo cVAR
cVAR=sprintf('They cost %s per %s',$99,100)
echo cVAR
cVAR=sprintf('Logicals can be %s or %s',.T.,.F.)
echo cVAR
// Formatting characters can contain a width, which will left pad with spaces
cVAR=sprintf('Right-justify and pad left: %10s this','Like')
echo cVAR
// Left justify by placing a '-' directly following the '%' character
cVAR=sprintf('Left-justify and pad right: %-10s this','Like')
echo cVAR
// %d is for numerics
cVAR=sprintf('It is %d',year(date()))
echo cVAR
// %t and %T are for formating datetime data types.
cVAR=sprintf('It is %d, %t to be more precise',year(date()),datetime())
echo cVAR
cVAR=sprintf('It is %d, %T to be even more precise',year(date()),datetime())
echo cVAR
// %f is for floating point numerics
cVAR=sprintf('The value of pi is %f',pi())
echo cVAR
// Decimal places can also be specified for floating point numerics (%f)
cVAR=sprintf('The value of pi to two decimal places is %4.2f',pi())
echo cVAR
// %y is for formatting currency data types
cVAR=sprintf('They cost %y per %d',$99,100)
echo cVAR
cVAR=sprintf('They cost %y per %d',$99,1000)
echo cVAR
cVAR=sprintf('They cost %y per %d',$99,10000)
echo cVAR
//%l and %L are for formatting logical datatypes.
cVAR=sprintf('Logicals can be %l or %l',.T.,.F.)
echo cVAR
cVAR=sprintf('Logicals can also be %L or %L',.T.,.F.)
echo cVAR
fp=fcreate('fprintf.txt')
// When %s is specified, the corresponding argument is converted to
// character format (similar to specifying etos()).
// Widths correspond to the default values, e.g. numerics are 10
fprintf(fp,'It is %s, %s to be more precise\n',year(date()),datetime())
fprintf(fp,'The value of pi is %s\n',pi())
fprintf(fp,'They cost %s per %s\n',$99,100)
fprintf(fp,'Logicals can be %s or %s\n',.T.,.F.)
// Formatting characters can contain a width, which will left pad with spaces
fprintf(fp,'Right-justify and pad left: %10s this\n','Like')
// Left justify by placing a '-' directly following the '%' character
fprintf(fp,'Left-justify and pad right: %-10s this\n','Like')
// %d is for numerics
fprintf(fp,'It is %d\n',year(date()))
// %t and %T are for formating datetime data types.
fprintf(fp,'It is %d, %t to be more precise\n',year(date()),datetime())
fprintf(fp,'It is %d, %T to be even more precise\n',year(date()),datetime())
// %f is for floating point numerics
fprintf(fp,'The value of pi is %f\n',pi())
// Decimal places can also be specified for floating point numerics (%f)
fprintf(fp,'The value of pi to two decimal places is %4.2f\n',pi())
// %y is for formatting currency data types
fprintf(fp,'They cost %y per %d\n',$99,100)
fprintf(fp,'They cost %y per %d\n',$99,1000)
fprintf(fp,'They cost %y per %d\n',$99,10000)
//%l and %L are for formatting logical datatypes.
fprintf(fp,'Logicals can be %l or %l\n',.T.,.F.)
fprintf(fp,'Logicals can also be %L or %L\n',.T.,.F.)
fclose(fp)
It is 2009, 11/11/2009 11:41:51 AM to be more precise
The value of pi is 3.1415926
They cost $99.0000 per 100
Logicals can be True or False
Right-justify and pad left: Like this
Left-justify and pad right: Like this
It is 2009
It is 2009, 11/11/2009 11:41:51 AM to be more precise
It is 2009, Wednesday November 11 2009 11:41:51 to be even more precise
The value of pi is 3.141593
The value of pi to two decimal places is 3.14
They cost $99.0000 per 100
They cost $99.0000 per 1000
They cost $99.0000 per 10000
Logicals can be True or False
Logicals can also be Yes or No
https://www.lianja.com/doc/index.php/Working_With_String_Data_in_Lianja
https://www.lianja.com/doc/index.php/Working_With_String_Data_in_Recital