This page documentes the syntax and language used in EpiData Manager and EpiData EntryClient for scripting.
We intend to reuse the syntax and much of the language features in a rewrite of EpiData Analysis.
Operation  Syntax  Example  Result 

Assignment  :=  X := 1  X has value 1 
Addition  +  3 + 2  5 
Subtraction    3  2  1 
Multiplication  *  3 * 2  6 
Divition  /  3 / 2  1.5 
Exponential  ^  3 ^ 2  9 
Modulus  mod  5 mod 2  1 
Integer division  div  5 div 2  2 
All relational operators returns a boolean value (that is true/false) based on the evaluation of the statement.
In the following table assume the values of variables as below:
X := 3; Y := 2; A := true; B := false;
Operation  Syntax  Example  Result 

Stric less than  <  X < Y  false 
Less than or equal  <=  X <= Y  false 
Stric greater than  >  X > Y  true 
Greater than or equal  >=  X >= Y  true 
Strict equal  =  X = Y  false 
Not equal  <>  X <> Y  true 
Not  not  not (A)  false 
Or  or  A or B  true 
And  and  A and B  false 
The scripting language in EpiData has similarities to the Pascal programming language.
The language construction is presented in Extended Backus–Naur Form:
<program> ::= <statementlist> <statementlist> ::= <statement> ";" [<statementlist>] <statement> ::= "begin" <statementlist> "end"  "if" <expression> "then" <statement> ["else" <statement>]  <variable> ":=" <expr>  "define" <variable> [{"," <variable>}]":" <type>  "goto" (<variable>"write") ["clear""missing"] <expression> ::= <expression> <operation> <expression>  "" <expression>  "not" <expression>  "(" <expression> ")"  <function> "(" [<expression> [{"," <expression>}]] ")"  <typecast> "(" <expression> ")"  <variable>  <integer literal>  <float literal>  <string literal>  "."  "true"  "false" <typecast> ::= <type> <type> ::= "integer"  "string"  "float"  "time"  "date" <operation> ::= "="  "<>"  "<"  "<="  ">"  ">="  "+"  ""  "*"  "/"  "^"  "or"  "and"  "mod"  "div"
Herligt
There is a number of built in functions in the scripting language. They are called, as stated above, with syntax: functionname(Param1, Param2,…)
In the table below we use the following letters to denote parameter and return types: i = integer, f = float, s = string, d = date, t = time n = number (interger or float)
Date (d) and integer(i) are interchangeable, ie. a date value can be assigned to an interger variable/paramter and vice versa. Time (t) and float(i) are interchangeable, ie. a time value can be assigned to a float variable/paramter and vice versa.
The difference between the interchangeable formats is, that when assignet to a string (variable or as an expression), date/time will be applied their appropriate formats where as integer/float will be formatted as the numbers they are. Internally date/integer and time/float are represented the same way, hence the value can be assigned to each others types.
Math functions:
Name:  Parameters:  Return type:  Example  Missing: 

abs(x)  n  (as input)  abs(12.34) = 12.34  If X is missing, then result is missing 
exp(x)  n  f  exp(1.234) = 3,43494186080076  
fraction(x)  f  f  fraction(1.342) = 0.34  
ln(x)  n  f  ln(12.34) = 2,51284601847724 ln(exp(1)) = 1  If X is missing, then result is missing. If X <= 0 then result is missing. 
log(x)  n  f  log(10) = 1 log(10^2) = 2 

round(x, digits)  n, i  f  round(12.34, 1) = 12.3 round(12.5, 0) = 13  If X is missing, then result is missing. If digits is missing then computation is halted! 
sqrt(x)  n  f  sqrt(4) = 2 sqrt(12.34) = 3,51283361405006  If X is missing, then result is missing. If X < 0 then result is missing. 
random(x)  i  i  Random integer from 1..X random(10) = 1..10 
Date functions:
Name:  Parameters:  Return type:  Example  Missing: 

createdate(x)  s  d  Returns a date based on the string input. If no format is specified (2nd parameter) then the function tries to guess the format. If the string is ambiguous then guessing defaults DMY format. Format can be “dmy”, “mdy” or “ymd”. createdate(“1122001”) = 1. dec. 2001 createdate(“1122001”, “mdy”) = 12th jan. 2001  If X or format is invalid, then computation is halted! 
createdate(x, format)  s, s  d  
createdate(day, month, year)  i, i, i  d  Returns a date based on the values createdate(1,12,2001) = 1. dec. 2001 createdate(., ., 2013) = 1. jan. 2013  if day and/or or are missing they are respectively set to 1 If year is missing then result is missing. 
today()    d  Returns today date  Result is always valid 
day(x)  d  i  day(24122001) = 24  If X is missing then result is missing 
month(x)  d  i  month(24122001) = 12  
year(x)  d  i  year(24122001) = 2001  
dayofweek(x)  d  i  dayofweek(24122001) = 2 Monday = 1, Sunday = 7 

week(x)  d  i  week(2222001) = 8 
Time functions:
Name:  Parameters:  Return type:  Example  Missing: 

createtime(x)  s  t  Returns a time based on the string input. The string MUST be in 24h format. createtime(“03:12:54”) createtime(“21:12:00”)  If X is invalid, then computation is halted! 
createtime(hour, minut, second)  i, i, i  d  Returna a date based on the values createtime(03, 12, 54) = 03:12:54 createtime(03, ., .) = 03:00:00  If minut and/or second are missing they are respectively set to 0. If hour is missing the result is missing 
now()    t  Returns current time  Result is always valid 
hour(x)  t  i  hour(03:12:54) = 3  If X is missing the result is missing 
minut(x)  t  i  minut(03:12:54) = 12  
second(x)  t  i  second(03:12:54) = 54 
String functions:
Name:  Parameters:  Return type:  Example  Missing: 

substring(x, pos, len)  s, i, i  s  substring(“abcdef”, 3, 2) = “cd”  If X is missing the result is missing. If pos or len are missing computation is halted! 
length(x)  s  i  length(“abcdef”) = 7 length(.) = 0  If X is missing the result 0. 
pos(x, substr)  s, s  i  pos(“abcdef”, “cd”) = 3 pos(“abcdef”, “z”) = 0 pos(., “a”) = 0  if either X or substr are missing result is 0 
trim(x)  s  s  trim(“ abcdef”) = “abcdef” trim(“abcdef ”) = “abcdef”  If X is missing then result is missing 
lower(x)  s  s  lower(“abCDef”) = “abcdef” lower(“abÆØef”) = “abæøef” ^{1)} 

upper(x)  s  s  upper(“abCDef”) = “ABCDEF” upper(“ABæøEF”) = “ABÆØEF” ^{2)} 