Go to the first, previous, next, last section, table of contents.


Packages

`files.chh'

Macro: frest (file)
Returns the not yet read contents of the file associated with the handle file.

Macro: fwholefile (filename)
Returns the whole contents of the file with the name filename.

Macro: fneweras (filename1,filename2)
Returns 1 if the modification time of the file with name filename1 is more recent than that of the file with name filename2 or if the file with name filename2 does not exist. Returns 0 otherwise.

`strings.chh'

Macro: replacesubstring (string,start,length,replacement)
Returns a string resulting from replacing the substring starting at index start with length length of string by the string replacement.

Macro: strneq (string1,string2)
Returns a boolean value of TRUE if string1 and string2 are not equal, otherwise TRUE.

`list.chh'

Macro: listSearch (list,criterion)
Returns the index of the first element of list for which the closure criterion, when called with that element as parameter, evaluates to boolean TRUE. Example

%listSearch(%list(a,bb,ccc,dddd),%lambda(e,%[%slength(%e)>=3]))
=> 2

Macro: listIndexOf (list,value)
Returns the index of the first element of list which is equal to value. Example:

%listIndexOf(%list(a,b,c,d),b)
=> 1

Macro: listMap (mapping,list[,list...])
All lists must have the same length, and mapping must be a closure taking as many arguments as there are lists. listMap creates a new list by applying mapping element-wise to the elements of the lists and storing the results in the corresponding elements of the resulting list. Example:

%listMap(%lambda(a,b,%[a+b]),%list(2,5,7),%list(4,2,9))
=> %list(%'6',%'7',%'16')

Macro: listLeftAccumulate (accumulator,list,zero)
If the length of list is 0, returns zero. Otherwise, accumulates all elements of list through accumulator, which must be a closure taking two arguments, in a left-associative way. Examples:

%listLeftAccumulate(%lambda(a,b,%[a+b]),%list(1,2,3),0)
=> 6
%listLeftAccumulate(%lambda(a,b,acc%'('%a%','%b%')'),
                    %list(a,b,c),zero)
=> acc(acc(a,b),c)

Macro: listRightAccumulate (accumulator,list,zero)
If the length of list is 0, returns zero. Otherwise, accumulates all elements of list through accumulator, which must be a closure taking two arguments, in a right-associative way. Examples:

%listRightAccumulate(%lambda(a,b,acc%'('%a%','%b%')'),
                     %list(a,b,c),zero)
=> acc(a,acc(b,c))

Macro: listJoin (string,list)
Joins the elements of the list list by inserting between two sequential elements the string string. Example:

%listJoin(:,%list(the,quick,brown,fox))
=> the:quick:brown:fox

`time.chh'

Time values are represented in chpp by hashes containing values for some of the following keys:

year
month
day
hour
minute
second

Macro: timeToString (format,time)
Converts a time value to a string according to the format string format. Ordinary characters in format are copied verbatim, while the dollar character ($), followed by any of the following characters is treated specially:

$
The character $.
d
The day of the month as a decimal number, beginning with 1 for the first day of the month.
m
The month as a decimal number, beginning with 1 for January.
b
The abbreviated month name.
B
The full month name.
Y
The year as a decimal number.
H
The hour as a decimal number (range 0 to 23).
M
The minute as a decimal number (range 0 to 59).
S
The second as a decimal number (range 0 to 59).

Example:

%timeToString($d $B $Y,%hash(day,29,month,12,year,1975))
=> 29 December 1975

Macro: timeFromString (format,string)
Converts the string string, which must obey the time format format, as described above, to a time value. Example:

%encode(%timeFromString($d $B $Y,29 December 1975))
=> %hash(%'year',%'1975',%'day',%'29',%'month',%'12')

`sql.chh'

This section describes chpp's interface to relational databases, called chdbc (chpp Database Connectivity). The interface is a layer above the client libraries for the various database servers, making it thus transparent to the user which database she is using.

Connections and results are represented by abstract datatypes. When passing a connection or result to a chdbc macro, do always pass the value which was returned by the creating macro, not a copy (i.e. use the reference form of variable access (see section Accessing Variables) to pass connection and result parameters).

Drivers are currently implemented for mSQL and MySQL. The latter takes a connection hash with keys user and password.

Macro: sqlConnect (url,hash)
Opens a connection to the SQL Server with the given url, which needs to be of the form chdbc:drivername://hostname[:port]/dbname/. A valid example would be chdbc:mysql://localhost/test/. hash must be hash containing information required by the driver to connect to the server, e.g. username and password. sqlConnect returns a value representing the connection to the server or a boolean value of FALSE if the connection could not be made.

Macro: sqlClose (connection)
Closes the database connection connection.

Macro: sqlDatabaseInfo (connection)
Returns a hash containing information about the database. The hash contains values for the following keys, if appropriate for the database:

timeformat
Format for time values which can be used in inserts and updates, like $H:$M:$S.
dateformat
Format for date values which can be used in inserts and updates, like $Y-$m-$d.
datetimeformat
Format for time plus date values which can be used in inserts and updates, like $Y-$m-$d $H:$M:$S.

Macro: sqlQuery (connection,querystring)
Performs a query on the database connected to by connection. Returns a value representing the result of the query or a boolean value of FALSE if the query could not be executed.

Macro: sqlResultData (result)
Returns the result rows of the query result result, as obtained by sqlQuery, in the form of a list. Each row in this list is represented as a hash whose keys are the column names of the result. Values for columns representing time (time, date and datetime) are automatically converted to chpp's time format (see section `time.chh').

Macro: sqlResultColumnInfo (result)
Returns a hash indexed by the column names of the query result result containing information about the columns. Each value contained in the hash is a hash containing values for the following keys:

type
Type of the column.

Macro: sqlResultColumnNames (result)
Returns a list containing the names of the column of the query result result.

Macro: sqlUpdate (connection,updatestring)
Performs an SQL statement contained in the string updatestring changing the data of the database connected to by connection, like an insert or an update.

`cgi.chh'

The package `cgi.chh' provides rudimentary support for CGI scripting.

Macro: cgiGetParameters ()
Returns a hash containing all parameters passed to the CGI script. Supported encodings are application/x-www-form-urlencoded (both GET and POST) and multipart/form-data.


Go to the first, previous, next, last section, table of contents.