Decrement memory variable by one
i=100 do while i > 0 --i enddo
https://www.lianja.com/doc/index.php/Decrement
Increment memory variable by one
i=0 do while i <100 ++ i enddo
https://www.lianja.com/doc/index.php/Increment
function func1 public m_var1 private m_var2 ? "m_var1 " + varinfo("m_var1") ? "m_var2 " + varinfo("m_var2") ? endfunc func1()
m_var1 Public m_var2 Private (FUNC1)
https://www.lianja.com/doc/index.php/VARINFO()
if isset(m_var) unset(m_var) endif
https://www.lianja.com/doc/index.php/UNSET()
if isset(m_var) // m_var exists endif
https://www.lianja.com/doc/index.php/ISSET()
local cTmpbuf ? cTmpbuf .F.
https://www.lianja.com/doc/index.php/LOCAL
public i as numeric, j as character, k
https://www.lianja.com/doc/index.php/PUBLIC
release i,j,k release all like code_* release all except c?de_* release all
https://www.lianja.com/doc/index.php/RELEASE
private i as numeric, j as character, k i = 42 ? k .F.
https://www.lianja.com/doc/index.php/PRIVATE
clear memory
https://www.lianja.com/doc/index.php/CLEAR_MEMORY
store "hello " to string1 store string1 + "world" to string2 ? string2 hello world area = length * width area = "change to a string"
https://www.lianja.com/doc/index.php/STORE
save to monday all like mon_* save to others all except mon_*
https://www.lianja.com/doc/index.php/SAVE
restore from monday additive
https://www.lianja.com/doc/index.php/RESTORE
use customers store automem clear automem
https://www.lianja.com/doc/index.php/CLEAR_AUTOMEM
set locktype to optimistic use customer store automem @1,1 get m.name @2,1 get m.address @3,1 get m.state read if not change() replace customer.name with m.name,; customer.address with m.address,; customer.state with m.state endif
https://www.lianja.com/doc/index.php/STORE_AUTOMEM
use addresses index add_1 seek "Seymour House" if found() scatter field like add* to aTemp endif
https://www.lianja.com/doc/index.php/SCATTER
function calledfunc if isset(cVar1) // returns .F. ? cVar1 endif if isset(cVar2) // returns .T. ? cVar2 endif endfunc set local on // default cVar1 = "I'm local" private cVar2 cVar2 = "I'm private" calledfunc()
https://www.lianja.com/doc/index.php/SET_LOCAL
set strict off m_var = date() set strict on private m_var m_var = date()
https://www.lianja.com/doc/index.php/SET_STRICT
Display the contents of the current memory variables
list memory
https://www.lianja.com/doc/index.php/LIST_MEMORY
display memory
https://www.lianja.com/doc/index.php/DISPLAY_MEMORY
procedure if(if) return if if = "hello" if if = "hello" echo if( if ) endif
There are no reserved words in Lianja. Command names can be used as variables names and database field variables.
https://www.lianja.com/doc/index.php/A_Lianja_Primer
private x x = 10 // x already exists y = 10 // y does not yet exist so it is created set strict on z = 10 // error is thrown as z does not exist and STRICT is ON
Variables in Lianja do not need to be explicitly declared, although they should be for better code readability and maintainability. When an expression is assigned to a variable, if the variable does not already exist then it will be created implicitly unless SET STRICT ON is in effect.
Simple Variables
Variable names must begin with a letter (A-Z, a-z) or an underscore (-), followed by any combination of letters, digits or underscores. The variable name can be of any length, but only the first 32 characters are significant, so these must be unique. Lianja ignores the case of letters, so m_var, M_VAR, and m_VaR would all be treated as the same memory variable name. The name given to a variable has no bearing on the type of data that is, or can be, stored in it. In fact, the type of data stored in a particular variable can be changed at any time unless SET STRICT is ON, in which case Lianja will type check variables on assigment to them.
m_var = 1234 m_var = 'a character value' ? m_var + 100
Variables can be declared and optionally initialized before used.
private m_var = 1234 m_var = 'a character value' ? m_var + 100
Variables can optionally be declared as specific datatype.
private m_var as numeric = 1234 m_var = 'a character value' // throws an error
https://www.lianja.com/doc/index.php/A_Lianja_Primer
Assigment Statements
The assignment statement stores the result of the expression expression into a variable.
variable = expression
If the variable does not exist and STRICT is OFF, then it is created. If the variable already exists, its contents are updated. If the variable does not exist (has not been declared) and STRICT is ON, then an error is thrown. When STRICT is ON, you should pre-declare variables before assigning values to them using the private, public or local commands.
private myvar set strict on // no error as myvar has already been declared myvar = "hello world" set strict off // error as newvar has not been declared newvar = 10
You can declare and initialize variables in one statement
private myvar = "hello world today is " + cdow( date() )
Lianja automatically performs type conversions for variables. If, for example, an existing variable called name contains a character string, and the command name=10 is executed, the variable will automatically be converted to a numeric variable.
If you explicitly tell Lianja what type of data can be stored in a variable, it will perform data type checking at runtime.
private myvar as character = "hello world today is " + cdow( date() ) // an error will be thrown because myvar was declared as a character myvar = 10
https://www.lianja.com/doc/index.php/A_Lianja_Primer
private nVar as numeric // Valid assignment nVar = 1234 // Throws error nVar = 'a character value'
public cVar1 as character, nVar1 private cVar2, nVar2 as numeric local cVar3, nVar3, dVar3 as date
public cVar1 as character cVar1 = 'start value' private cVar1 as character cVar1 = 'start value' local cVar1 as character cVar1 = 'start value' store 'new value' to cVar1 cVar1 = 'newer value'
store 'new value' to cVar1, cVar2
nVar = 1234 echo nVar echo m.nVar echo m->nVar
if isset(nVar) // nVar exists endif
if isset(nVar) unset(nVar) endif
private cVar as character cVar = "Hello World" ? type("cVar") C ? is_string(cVar) .T.
private nVar as numeric nVar = -12.34 ? type("nVar") N ? is_float(nVar) .T. ? is_int(nVar) .T.
private dVar as date dVar = date() ? type("dVar") D
private lVar as logical lVar = .T. ? type("lVar") L
private tVar as datetime tVar = datetime() ? type("tVar") T
private yVar as currency yVar = $99.99 ? type("yVar") Y
https://www.lianja.com/doc/index.php/Lianja_Variables_and_Constants
Variables
Variables in Lianja do not need to be explicitly declared, although they should be for better code readability and maintainability. When an expression is assigned to a variable, if the variable does not already exist then it will be created implicitly unless SET STRICT ON is in effect.
private x x = 10 // x already exists y = 10 // y does not yet exist so it is created set strict on z = 10 // error is thrown as z does not exist and STRICT is ON
Simple Variables
Variable names must begin with a letter (A-Z, a-z) or an underscore (-), followed by any combination of letters, digits or underscores. The variable name can be of any length, but only the first 32 characters are significant, so these must be unique. Lianja ignores the case of letters, so m_var, M_VAR, and m_VaR would all be treated as the same memory variable name. The name given to a variable has no bearing on the type of data that is, or can be, stored in it. In fact, the type of data stored in a particular variable can be changed at any time unless SET STRICT is ON, in which case Lianja will type check variables on assigment to them.
m_var = 1234 m_var = 'a character value' ? m_var + 100
Variables can be declared and optionally initialized before used.
private m_var = 1234 m_var = 'a character value' ? m_var + 100
Variables can optionally be declared as specific datatype.
private m_var as numeric = 1234 m_var = 'a character value' // throws an error
Keywords
There are no reserved words in Lianja. Command names can be used as variables names. At first glance this seems strange, but provides for greater flexibility when declaring and referencing memory variables and database field variables, as you do not need to concern yourself about names that may already be used as commands.
As an extreme example, the following code will compile and run. It will output “hello”
procedure if(if) return if if = "hello" if if = "hello" echo if( if ) endif
Statements
The statement is the basic unit of programming in any programming language. Statements in Lianja are delimited by a newline.
echo "Hello world"
You can extend statements over multiple lines by placing a ‘;’ at the end of the line:
echo "Hello ; world" + ; " this is a multi-line statement"
Assigment Statements
The assignment statement stores the result of the expression expression into a variable.
variable = expression
If the variable does not exist and STRICT is OFF, then it is created. If the variable already exists, its contents are updated. If the variable does not exist (has not been declared) and STRICT is ON, then an error is thrown. When STRICT is ON, you should pre-declare variables before assigning values to them using the private, public or local commands.
private myvar set strict on // no error as myvar has already been declared myvar = "hello world" set strict off // error as newvar has not been declared newvar = 10
You can declare and initialize variables in one statement
private myvar = "hello world today is " + cdow( date() )
https://www.lianja.com/doc/index.php/A_Recital_Primer