Keywords: teapot

## Functions

This section documents all available functions in alphabetical order. The functions are given in a C-like notation, so use `@(0,0,0)` instead of `@(integer 0, integer 0, integer 0)`. If no type is given for the result of a function, it means the result type depends on the arguments. Brackets mark optional arguments.

@([int x][,[int y][,[int z]]])
@(location l)
  returns the value of the cell at position x, y, z. If any of x, y or z is omitted, the coordinate of the cell is used.
location &([int x][, [int y][, [int z]]])
  returns a pointer to the cell at location x, y, z. If z is omitted, the z position of the current cell is used. If y is missing as well, the y position (row) of the cell is used.
string $(string env)
  evaluates to the contents of the specified environment variable. If the variable does not exist, then an empty string will be returned.
float abs(float x)
int abs(int x)
  evaluates to the absolute value of x.
float acos(float|int x)
  evaluates to the arc cosine of x, where x is given in radians.
float arcosh(float|int x)
  evaluates to the arc hyperbolic cosine of x, where x is given in radians.
float arsinh(float|int x)
  evaluates to the arc hyperbolic sine of x, where x is given in radians.
float artanh(float|int x)
  evaluates to the arc hyperbolic tangent of x, where x is given in radians.
float asin(float|int x)
  evaluates to the arc sine of x, where x is given in radians.
float atan(float|int x)
  evaluates to the arc tangent of x, where x is given in radians.
clock(integer condition,[location[,location])
  conditionally clocks the specified cell if the condition is not 0. If two locations are given, all cells in that range will be clocked. The return value of clock is empty.
float cos(float|int x)
  evaluates to the cosine of x, where x is given in radians.
float cosh(float|int x)
  evaluates to the hyperbolic cosine of x, where x is given in radians.
float deg2rad(float|int x)
  evaluates to the degrees that are equivalent to x radians.
float e()
  evaluates to the Euler constant e.
error error(string message)
  evaluates to an error with the specified message.
eval(location)
  evaluates to the value of the expression in the cell at the given location, but evaluated in the context of the cell using eval(). This function may not be used nested any deeper than 32 times.
float float(string s)
  converts the given string into a floating point number.
float frac(float x)
  evaluates to the fractional part of x.
int int(float x[,integer neg, integer pos])
  converts x to an integer value by cutting off the fractional part. If given, the value of neg and pos determines how negative and non-negative numbers will be converted:

> neg/pos | Result
> < -1 | next smaller integer value
> -1 | round downward
> 0 | cut fractional part off (default)
> 1 | round upward
> > 1 | next larger integer value

int int(string s)
  converts s to an integer number.
string len(string s)
  evaluates to the length of s.
float log(float|int x[,float|int y)
  evaluates to the logarithm of x. If y is specified, the result will be the natural logarithm, otherwise it will be the logarithm to the base of y.
location max(location l1, location l2)
  evaluates to the maximum in the same way min does for the minimum.
location min(location l1, location l2)
  evaluates to the location of the minimum of all values in the block marked by the corners pointed to by l1 and l2. Note that the empty cell is equal to 0, 0.0 and , so if the first minimum is an empty cell, the result will be a pointer to this cell, too. If you are not interested in the location of the minimum but the value itself, use @(min(l1, l2)).
int n(location l1, location l2)
  evaluates to the number of non-empty cells in the block marked by the corners pointed to by l1 and l2.
poly(float|integer x, float|integer cn[, ...])
  evaluates the polynome .
float rad2deg(float|int x)
  evaluates to the radians that are equivalent to x degrees.
float rnd()
  evaluates to a pseudo-random number between 0.0 and 1.0.
float sin(float|int x)
  evaluates to the sine of x, where x is given in radians.
float sinh(float|int x)
  evaluates to the hyperbolic sine of x, where x is given in radians.
string strftime(string f [, integer t])
  evaluates to the time t formatted according to the format specified in f. Times in t are counted in seconds since epoch (1970-1-1 0:00). If t is empty or 0, the actual time is used. For the format specifications consult the man page of your c library, strftime (3). Example: @(now)=int(strftime(%s)) sets the field with label now to the actual time.
string string(location l)
string string(integer x)
string string(float x[, [integer precision][, integer scientific]])
  evaluates to a string containing the current value of the given cell at location l, or to the numeric value x with the given precision. The scientific flag determines if decimal (0) or scientific (unequal 0) representation is used.
int strptime(string f, string datetime)
  evaluates to the seconds since epoch (1970-1-1 0:00) of the datetime string, parsed according to the format specified in f. For the format specifications consult the man page of your c library, strptime (3).
string substr(string s,integer x,integer y)
  evaluates to the substring of s between x and y, which start at 0.
sum(location l1, location l2)
  evaluates to the sum of all values in the block marked by the corners pointed to by l1 and l2.
float tan(float|int x)
  evaluates to the tangent of x, where x is given in radians.
float tanh(float|int x)
  evaluates to the hyperbolic tangent of x, where x is given in radians.
int x([location l])
int y([location l])
int z([location l])
  evaluate to the x, y and z position of the given location, of the currently updated cell if none is given. These functions are usually used in combination with the @ function for relative relations to other cells.