This is Info file chpp.info, produced by Makeinfo version 1.68 from the input file chpp.texi. This file documents the `chpp' Preprocessor. Copyright (C) 1997-1999, Mark Probst, Heinz Deinhart Permission is granted to make and distribute verbatim copies of this manual provided the copyright notice and this permission notice are preserved on all copies. START-INFO-DIR-ENTRY * chpp:: A very powerful macro preprocessor. END-INFO-DIR-ENTRY  File: chpp.info, Node: Special Forms, Next: Macro Reference, Prev: Extending chpp, Up: Top Special Forms ************* Special forms, although syntactically equivalent to macros, differ from macros in that their arguments are not automatically evaluated before they are called. The evaluation of their arguments usually depend on some condition of some other argument. - Special Form: if (CONDITION,CONSEQUENT[,ALTERNATIVE]) Evaluates CONDITION and, if its boolean value is TRUE, evaluates CONSEQUENT. Otherwise, ALTERNATIVE is evaluated, if specified. - Special Form: cond ([CONDITION,CONSEQUENT[,...]]) Evaluates the CONDITIONs one at a time and checks for their boolean value. If a CONDITION with a value of TRUE is encountered, its corresponding CONSEQUENT is evaluated and its result returned. If no CONDITION evaluates to TRUE, nothing is done. Example: %\ %cond(%[number < 10],less than 10, %[number < 50],less than 50 but greater than 9, else,greater than 49) => less than 50 but greater than 9 - Special Form: case (STRING,LIST,CONSEQUENT[,...[,`else',ALTERNATIVE]]) Evaluates STRING to a scalar. Then, one at a time evaluates each LIST and checks whether STRING is contained in the resulting list. If it is, the corresponding CONSEQUENT is evaluated and its result returned. If the `else' clause is specified and the string is contained in no list, its ALTERNATIVE is evaluated. Otherwise, nothing is done. Example: %\ %case(%number, %list(0,2,4,6,8),even, %list(1,3,5,7,9),odd) => odd - Special Form: for (COUNTER,START,STOP,[INCREMENT,]BODY) Evaluates COUNTER, START, STOP and, if specified, INCREMENT. The values of START, STOP and INCREMENT must be integer numbers. If INCREMENT is not specified, an increment of 1 is used if START is greater than STOP, otherwise -1. Then counts, beginning with START, while the value of the counter is before or equal to STOP in the counting direction. For each step, evaluates BODY in a new environment where COUNTER is bound to the value of the counter. A few examples: %for(i,1,10,%i%' ') => 1 2 3 4 5 6 7 8 9 10 %for(i,10,1,%i%' ') => 10 9 8 7 6 5 4 3 2 1 %for(i,1,10,2,%i%' ') => 1 3 5 7 9 %for(i,10,1,-2,%i%' ') => 10 8 6 4 2 %for(i,1,10,0,%i%' ') error--> increment in for-loop cannot be zero %for(i,10,1,1,%i%' ') => - Special Form: foreach (COUNTER,LIST,BODY) Evaluates COUNTER and LIST, which must yield a list. Then iterates over this list evaluating BODY in a new environment in which COUNTER is bound to the current list element. - Special Form: foreachkey (COUNTER,HASH,BODY) Evaluates COUNTER and HASH, which must yield a hash. Then iterates over all keys in the hash evaluating BODY in a new environment in which COUNTER is bound to the current hash key. - Special Form: while (CONDITION,EXPR) Evaluates CONDITION. If this yields a boolean value of TRUE, EXPR is evaluated, otherwise the loop is finished. Then repeats the cycle. - Special Form: until (CONDITION,EXPR) Evaluates CONDITION. If this yields a boolean value of TRUE, the loop is finished, otherwise EXPR is evaluated. Then repeats the cycle. - Special Form: dowhile (EXPR,CONDITION) Evaluates EXPR, then evaluates CONDITION. If this yields a boolean value of TRUE, the cycle is repeated. - Special Form: dountil (EXPR,CONDITION) Evaluates EXPR, then evaluates CONDITION. If this yields a boolean value of TRUE, the loop is finished, otherwise the cycle is repeated. - Special Form: and ([EXPR[,...]]) Evaluates the EXPRs from left to right. For the first EXPR evaluating to boolean FALSE, returns `0'. If all EXPRs evaluate to boolean TRUE, returns `1'. This means that if one EXPR evaluates to FALSE, all EXPRs to its right do not get evaluated. If `and' is called without parameters, it returns `1'. - Special Form: or ([EXPR[,...]]) Evaluates the EXPRs from left to right. For the first EXPR evaluating to boolean TRUE, returns `1'. If all EXPRs evaluate to boolean FALSE, returns `0'. This means that if one EXPR evaluates to TRUE, all EXPRs to its right do not get evaluated. If `or' is called without parameters, it returns `0'. - Special Form: define (NAME,ARGNAME[,ARGNAME...],BODY) Defines a macro with the name NAME and the specified argument names. The body BODY is not evaluated. If the last ARGNAME matches the pattern LSTNAME`:'[LOWER]`:'[UPPER] then the macro takes a variable number of arguments. All ARGNAMEs but the last are treated as single arguments. The last ARGNAME corresponds to a number of arguments not less than LOWER and not greater than UPPER. When the macro is called, these arguments are bound to the LSTNAME in the form of a list. If LOWER is not given, zero arguments for LSTNAME are allowed. If UPPER is not given, there is no upper limit on the number of arguments. Examples: %define(mac,a,b,a=%a b=%b) defines a macro `mac' taking exactly two arguments. %define(mac,a,b,c:2:3,a=%a b=%b c=%encode(%c)) %mac(1,2,3,4) => a=1 b=2 c=%list(%'3',%'4') defines a macro `mac' taking four or five arguments. %define(mac,a,b,c::3,a=%a b=%b c=%encode(%c)) defines a macro `mac' taking at most five arguments. %define(mac,a,b,c:2:,a=%a b=%b c=%encode(%c)) defines a macro `mac' taking at least four arguments. - Special Form: defspecial (NAME,ARGNAME[,ARGNAME...],BODY) Defines a special form with the name NAME and the specified argument names. The body BODY is not evaluated. When a special form is called, its arguments are not evaluated. This is left to the special form. Instead, intermediate code of the arguments is bound to the ARGNAMEs and BODY is evaluated. The special form can evaluate any of the arguments any time it wishes to by using the `eval' macro. The special form body is evaluated in an environment whose parent is the environment from which the special form was invoked. As an example, we give an implementation of a special form `unless' which evalutes its second argument only if its first argument evaluates to a boolean value of FALSE: %defspecial(unless,cond,body, %if(%not(%eval(%cond)), %eval(%body) ) ) Note that any side-effects that result from evalutating the second argument do not occur if the first argument evaluates to TRUE: % %unless(1,%) %%a is %a => %a is 123 - Special Form: lambda (ARGNAME[,ARGNAME...],BODY) Creates an anonymous macro (closure) with the specified argument names and the body BODY, which is not evaluated. If the last ARGNAME matches the pattern LSTNAME`:'[LOWER]`:'[UPPER] then the closure takes a variable number of arguments. The semantics of this feature are equal to that of `define'. The definition %define(mac,a,b,a=%a b=%b) is semantically equivalent to % - Special Form: let (NAME,VALUE[,NAME,VALUE...],BODY) Evaluates BODY in a new environment with the local variables NAMEs bound to their corresponding VALUEs. The variables are bound beginning with the first NAME from left to right and the bindings are immediately visible to the following VALUE expressions, i.e. the second VALUE is evaluated in an environment where the first NAME is already bound. This is a behaviour similar to Lisp's `let*'. %let(a,1,b,%[a+1],%%a=%a %%b=%b) => %a=1 %b=2 - Special Form: locals (SYMBOL[,SYMBOL...],BODY) Evaluates BODY in a new environment with the specified local variables.  File: chpp.info, Node: Macro Reference, Next: Internal Variables, Prev: Special Forms, Up: Top Macros ****** * Menu: * List Operations:: * Hash Operations:: * Environment Operations:: * File Operations:: * String Operations:: * Time Operations:: * Miscellaneous::  File: chpp.info, Node: List Operations, Next: Hash Operations, Prev: Macro Reference, Up: Macro Reference List Operations =============== - Macro: list ([ELEMENT,...]) Returns a list containing all specified ELEMENTs in the specified order, beginning with index 0. Note that `%list()' returns an empty list while `%list(%'')' returns a list with one element, which is the empty string. - Macro: llength (LIST) Returns the number of elements in the list LIST. - Macro: linsert (LIST,INDEX,ELEMENT) Inserts the element ELEMENT into the list LIST at index INDEX. If INDEX is greater or equal the length of LIST, the list is enlarged by appending empty strings. Examples: % %linsert(%&lst,1,x)%encode(%lst) => %list(%'a',%'x',%'b',%'c') %linsert(%&lst,5,y)%encode(%lst) => %list(%'a',%'x',%'b',%'c',%'',%'y') - Macro: ldelete (LIST,INDEX) Deletes from the list LIST the element at index INDEX. Example: %%ldelete(%&lst,1)%encode(%lst) => %list(%'a',%'c') - Macro: lsort (LIST[,COMPARATOR]) Sorts the elements of the list LIST, which should be strings, according to the order specified by COMPARATOR, which must be a closure taking two arguments and returning an integer. A return value of `0' denotes that the two arguments are equal, less than `0' means that the first argument should come before the second, greater than `0' means that the first argument should come after the second. If COMPARATOR is omitted, the macro `scmp' is used. Returns the resulting list. Examples: %encode(%lsort(%list(b,c,a))) => %list(%'a',%'b',%'c') %encode(%lsort(%list(b,c,a),%lambda(a,b,%scmp(%b,%a)))) => %list(%'c',%'b',%'a') - Macro: lappend (LIST,VALUE[,VALUE...]) Appends all VALUEs to the list LIST. Returns nothing, i.e. is called for its side effects, which means that the first parameter should be a list to be modified, not a copy of a list. - Macro: luniq (LIST[,COMPARATOR]) Removes all but the first occurrences of all sequential occurrences of the same element in LIST, where the sameness is determined by the closure COMPARATOR, which must accept two arguments and return a boolean value of TRUE if they are equal, FALSE otherwise. If COMPARATOR is omitted, `seq' is used. Returns the modified LIST. %encode(%luniq(%list(a,b,b,c,d,e,e,e,f))) => %list(%'a',%'b',%'c',%'d',%'e',%'f')  File: chpp.info, Node: Hash Operations, Next: Environment Operations, Prev: List Operations, Up: Macro Reference Hash Operations =============== - Macro: hash ([KEY,VALUE,...]) Returns a hash containing all the specified key/value pairs. - Macro: hcount (HASH) Returns the number of key/value pairs in the hash HASH. - Macro: hcontains (HASH,KEY) Returns `1', if the key KEY is contained in the hash HASH. Otherwise, returns `0'. - Macro: hkeys (HASH) Returns a list of all keys in the hash HASH in no particular order. - Macro: hdelete (HASH,KEY) Removes the key KEY from the hash HASH. Does nothing if KEY is not contained in HASH. % %hdelete(%&h,b) %encode(%h) => %hash(%'a',%'1',%'c',%'3')  File: chpp.info, Node: Environment Operations, Next: File Operations, Prev: Hash Operations, Up: Macro Reference Environment Operations ====================== - Macro: envThis () Returns the environment which the macro is executed in. - Macro: envNew ([PARENT]) Returns a new environment. If PARENT is specified, it is used as the parent to the newly created environment. Otherwise, the new environment is a top-level environment, i.e. has no parent. - Macro: envAdd (ENV,NAME,VALUE) Adds a binding for the name NAME to the value VALUE to the environment ENV.  File: chpp.info, Node: File Operations, Next: String Operations, Prev: Environment Operations, Up: Macro Reference File Operations =============== - Macro: fopen (FILENAME[,MODE]) Opens the file named FILENAME and returns a handle to it. If the file could not be opened, for example because it does not exists, for lack of permission or if MODE is illegal, returns `-1'. MODE describes for what purposes the file is opened and must be one of the following: `r' Reading. `w' Writing. `a' Appending. If MODE is omitted, the file is opened for reading. - Macro: fpipe (MODE,EXECUTABLE[,ARG...]) Forks off a child process, starts the specified executable with the specified parameters. If MODE is `r', returns a handle for reading the processes standard output. If MODE is `w', returns a handle for writing to the processes standard input. Returns `-1' if something goes wrong. Note that the arguments are not subject to shell expansion, since the process does not start a subshell. If you want shell expansion, you have to start a subshell explicitly. For example, to list all files beginning with an `a': %fpipe(r,/bin/sh,-c,ls a*) - Macro: fclose (FILE) Closes the file associated with the handle FILE. - Macro: fgets (FILE) Reads one line from the file associated with the handle FILE and returns it. The newline character is included. - Macro: fputs (FILE,STRING) Writes STRING to the file associated with the handle FILE, which must have been opened for writing. - Macro: feof (FILE) Returns boolean TRUE if the end of the file associated with the handle FILE is reached, FALSE otherwise. - Macro: fstat (FILENAME) Returns a hash containing information on the file with name FILENAME. Returns an empty hash if the file does not exist. Otherwise, the hash contains values for the following keys: `uid' User ID of owner. `gid' Group ID of owner. `size' Size in bytes. `blksize' Blocksize for filesystem I/O. `blocks' Number of blocks allocated. `atime' Time of last access. `mtime' Time of last modification. `ctime' Time of last change. All times are given in seconds since January 1, 1970, 00:00:00 GMT. For detailed description of these values see `stat(2)'. - Macro: fgetwd () Returns the current working directory. - Macro: fchdir (PATH) Changes the current working directory to PATH. - Macro: fglob (PATTERN) Matches the pattern string PATTERN using shell pattern matching rules. Returns a list of all filenames matched or boolean FALSE if no filenames could be matched or in case of an error. %encode(%fglob(/b*)) => %list(%'/bin',%'/boot')  File: chpp.info, Node: String Operations, Next: Time Operations, Prev: File Operations, Up: Macro Reference String Operations ================= - Macro: smatch (REGEXP,STRING[,REGISTERS]) Searches the string STRING for the first occurrence of the regular expression REGEXP and returns the index of the first character of this substring. If no match was found, returns `-1'. If REGISTERS is specified, which must be a list, clears it and sets its elements (beginning with 1) to the contents of the corresponding submatches (parts of the regular expression enclosed by parentheses). The element `0' is set to the whole match. For example: %\ %smatch(%'\.([^.]*)$',alittlepicture.jpg,%®s) %regs[1] => 14 jpg - Macro: ssplit (REGEXP,STRING[,CONNECTOR]) Splits the string STRING into parts separated by the regular expression REGEXP. Returns a list containing these parts. If CONNECTOR is specified, the parts that are inserted into the list are generated by invocations of CONNECTOR. CONNECTOR is always called with three parameters, the first being the registers of REGEXP for the match right before the string and the third being the registers of the match right after the string. The second parameter is the string itself. For the very first string, the first parameter is an empty list, whereas for the last string, the third parameter is an empty list. Thus %ssplit(%regex,%string) is equivalent to %ssplit(%regex,%string,%lambda(a,b,c,%b)) Example: %encode(%ssplit(:+,foo::bar:rules)) => %list(%'foo',%'bar',%'rules') - Macro: stokenize (REGEXP,STRING[,TOKENER]) Returns a list containing all substrings of STRING matching REGEXP. If TOKENER is specified, not the whole matches are inserted into the result list, but the results of calling TOKENER with the respective lists of registers of the matches. This means, that these two calls have the same result: %stokenize(%regexp,%string) %stokenize(%regexp,%string,%lambda(r,%r[0])) Examples: %encode(%stokenize([a-zA-Z0-9]+,%' a bc d04 d fsfd, rwe')) => %list(%'a',%'bc',%'d04',%'d',%'fsfd',%'rwe') %encode(%stokenize(%'-([0-9]+)-',%' -32- -- 543 -12--43--', %lambda(r,%r[1]))) => %list(%'32',%'12',%'43') - Macro: sgsub (REGEXP,STRING,REPLACEMENT[,OPTIONS]) Replaces all occurrences of the regular expression REGEXP in STRING. If REPLACEMENT is a string, the occurrences are replaced with this string. Otherwise, REPLACEMENT must be a closure taking one argument and returning a string. In this case, the occurrences are replaced by the result of the closure when called with a list containing the regular expression registers in elements beginning with `1' and the whole match in element `0'. OPTIONS, if specified, should be a string composed of one or more of the following characters: `i' Match case insensitively. The default is case-sensitive matching. Examples: %sgsub(ei,HEINZI Deinzi,!,i) => H!NZI D!nzi %sgsub(a+,abaacaaadaaaa,%lambda(r,%slength(%r[0]))) => 1b2c3d4 - Macro: sremovews (STRING) Returns a string which results from removing all leading and trailing whitespace from the string STRING. - Macro: slength (STRING) Returns the length of the string STRING. - Macro: ssub (STRING,START[,LENGTH]) Returns a substring of the string STRING. If it is called with two arguments and START is positive, then the substring beginning with index START is returned. If START is negative, the last -START characters are returned. If called with two arguments, START specifies the index of the first character in the substring. If LENGTH is positive, it specifies the length of substring. If it is negative, then -LENGTH specifies the index of the character following the last character of the substring. Examples: %substring(0123456789,3) => 3456789 %substring(0123456789,-3) => 789 %substring(0123456789,2,3) => 234 %substring(0123456789,2,-5) => 234 - Macro: scmp (STRING1,STRING2) Returns the result of the `strcmp()' C function with STRING1 and STRING2. - Macro: schr (CODE) Returns a string with the character with character code CODE. - Macro: snumber (NUMBER,BASE) Formats the decimal integer NUMBER according to the given base BASE, which must be between 2 and 36 inclusive. Example: %snumber(34,2) => 100010 %snumber(-255,16) => -ff - Macro: srange (CHAR1,CHAR2) Generates a string by concatenating all characters between and including CHAR1 and CHAR2. Example: %srange(a,f) => abcdef - Macro: smap (SRC,DEST,STR) Returns a string where all characters of the string STR included in SRC are translated to characters at the same position in DEST. SRC and DEST must be strings of the same length. Example: %smap(%srange(a,z),%srange(A,Z),Heinzi Deinzi) => HEINZI DEINZI  File: chpp.info, Node: Time Operations, Next: Miscellaneous, Prev: String Operations, Up: Macro Reference Time Operations =============== Time values are represented in `chpp' by hashes containing values for some of the following keys: `year' `month' `day' `hour' `minute' `second' - Macro: timeUNIX () Returns the current time in UNIX `time_t' format. %timeUNIX() => 917465546 - Macro: timeUNIX2Hash (UTIME) Returns a time hash that corresponds to the UNIX time UTIME. %<(%timeUNIX2Hash(917465546)){year}> => 1999 - Macro: timeHash2UNIX (HTIME) Returns the UNIX time corresponding to the time hash HTIME. The hash must contain sane values for at least the keys `second', `minute', `hour', `day', `month' and `year'.  File: chpp.info, Node: Miscellaneous, Prev: Time Operations, Up: Macro Reference Miscellaneous ============= - Macro: void (EXPR) Executes EXPR but discard the result. Example: %\ %void(%smatch(%'\.([^.]*)$',alittlepicture.jpg,%®s))%regs[1] => jpg - Macro: outputenable (FLAG) If the boolean value of FLAG is TRUE, enables output, otherwise disables it. If output is disabled, everything is evaluated as usual, but `chpp' does not output anything. - Macro: depend (DEPENDENCY[,TARGET]) Adds the filename DEPENDENCY to the list of dependencies for the file TARGET. If TARGET is not specified, the name of the output file is used. - Macro: warning (MESSAGE) Causes `chpp' to give a warning with the message MESSAGE. - Macro: error (MESSAGE) Causes `chpp' to signal an error with the message MESSAGE. - Macro: encode (VALUE) Returns a string which, upon evaluation, yields a value equal to VALUE. - Macro: random (LIMIT) Returns a random number in the interval 0 to LIMIT-1. The random number are uniformly distributed. - Macro: same (VAL1,VAL2) Returns `1' if VAL1 and VAL2 refer to the same value, otherwise `0'. Two values are the same if a change in one entails the same change in the other, i.e. if they occupy the same memory location. Examples: %%same(%val,%val) => 0 %%same(%&val,%&val) => 1 %%%same(%&val,%&val2) => 1 - Macro: equal (VAL1,VAL2) Returns `1' if VAL1 is equal to VAL2, otherwise `0'. Two scalars are equal if the strings they contain are equal. Two lists are equal if they have the same length and contain equal elements. Two hashes are equal if they have the same count and the same keys map to equal values. %equal(%list(a,b,c),%list(a,b,c)) => 1 %equal(%hash(a,1,b,2,c,3),%hash(c,3,b,2,a,1)) => 1 %equal(%list(a,b,c),%list(1,2,3)) => 0 - Macro: typeof (VALUE) Returns the type of VALUE. The result can be one of `scalar', `list', `hash', `lambda', `built-in'. %typeof(abc) => scalar %typeof(%list(a,b,c)) => list %typeof(%hash(a,1,b,2,c,3)) => hash %typeof(%lambda(a,%a%a)) => lambda %typeof(%typeof) => built-in - Macro: bound (NAME) Returns `1' if the name NAME is bound in the current environment. If not, returns `0'. - Macro: apply (LAMBDA,ARGLIST) Calls LAMBDA with the elements of ARGLIST as arguments. %apply(%lambda(a,b,c,my args are %a %b %c),%list(1,2,3)) => my args are 1 2 3 - Macro: eval (CODE[,ENV]) Evaluates the code CODE in the the environment ENV or in the local environment if ENV is not specified. %let(a,xyz,%eval(%%a)) => xyz %let(e,%envNew(),%envAdd(%&e,a,xyz)%eval(%%a,%&e)) => xyz - Macro: not (EXPR) Returns the negation of the boolean value of EXPR, i.e. returns `1' if EXPR is FALSE and `0' if EXPR is TRUE. - Macro: shexencode (STRING) Translates the bytes of STRING to a sequence of hexadecimal digits. %shexencode(hello world!) => 68656C6C6F20776F726C6421 - Macro: shexdecode (STRING) Translates a sequence of hexadecimal digits as produced by `shexencode' to a string. %shexdecode(68656C6C6F20776F726C6421) => hello world!  File: chpp.info, Node: Internal Variables, Next: Package Reference, Prev: Macro Reference, Up: Top Internal Variables ****************** - Variable: outputenabled Is `1' if output is enabled, `0' otherwise. Output can be enabled and disabled with the macro `outputenable'. - Variable: dependencing Is `1' if `chpp' was started to generate dependencies (option `--generate-dependencies'), `0' otherwise. - Variable: mainfilename Is set to the filename of the currently executed top-level source file. - Variable: env Is a hash containing all environment variables of the process. %env{TERM} => xterm  File: chpp.info, Node: Package Reference, Next: Macro Index, Prev: Internal Variables, Up: Top Packages ******** * Menu: * files.chh:: * strings.chh:: * list.chh:: * time.chh:: * sql.chh:: * cgi.chh:: * w3lib.chh::  File: chpp.info, Node: files.chh, Next: strings.chh, Prev: Package Reference, Up: Package Reference `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.  File: chpp.info, Node: strings.chh, Next: list.chh, Prev: files.chh, Up: Package Reference `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.  File: chpp.info, Node: list.chh, Next: time.chh, Prev: strings.chh, Up: Package Reference `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  File: chpp.info, Node: time.chh, Next: sql.chh, Prev: list.chh, Up: Package Reference `time.chh' ========== - Macro: timeNow () Returns a time hash for the current time. - 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')  File: chpp.info, Node: sql.chh, Next: cgi.chh, Prev: time.chh, Up: Package Reference `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 (*note 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 (*note 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.  File: chpp.info, Node: cgi.chh, Next: w3lib.chh, Prev: sql.chh, Up: Package Reference `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'.  File: chpp.info, Node: w3lib.chh, Prev: cgi.chh, Up: Package Reference `w3lib.chh' =========== This package provides rudimentary support for web page building. It requires the program `xli' to parse picture files. There is some experimental JavaScript code in `w3lib.chh', but nothing is used by now. If you are a JavaScript guru you might want to code a bit? - Variable: w3xliExecutable If set before `w3lib.chh' is included, it will use this as full path to the `xli' program. - Macro: w3img (IMAGENAME,[ARG...]) - Macro: w3image (IMAGENAME,[ARG...]) Generates an `img' tag for IMAGENAME. If ARGs are supplied the will be added at the end of the `img' tag. `w3img' takes care of dependencies. - Macro: w3imgX (IMAGENAME) - Macro: w3imgWidth (IMAGENAME) Returns the width of the image IMAGENAME. Takes care of dependencies. - Macro: w3imgY (IMAGENAME) - Macro: w3imgHeight (IMAGENAME) Returns the height of the image IMAGENAME. Takes care of dependencies. - Macro: w3rgbcolor (RED,GREEN,BLUE) Returns an HTML conforming color value string. `w3lib.chh' is intended to be used together with `make'. A simple `Makefile' may look like this: # chpp Makefile for web pages HTML = Main.html News.html Authors.html Manual.html Wizard.html \ Download.html Links.html # --- general ---------------------------------------------------------------- all : $(HTML) clean : rm -f *.d *.jpgd *.gifd *.pngd *.html core *~ # --- chpp dependencies ------------------------------------------------------ %.html : %.csml chpp $< > $ %.d : %.csml chpp -M -o $(<:.csml=.html) $< > $ # --- includes --------------------------------------------------------------- -include $(HTML:.html=.d)  File: chpp.info, Node: Macro Index, Prev: Package Reference, Up: Top Macro Index *********** * Menu: * and: Special Forms. * apply: Miscellaneous. * bound: Miscellaneous. * case: Special Forms. * cgiGetParameters: cgi.chh. * cond: Special Forms. * define <1>: Special Forms. * define: Command Reference. * defspecial: Special Forms. * depend: Miscellaneous. * disc: Command Reference. * discard: Command Reference. * dountil: Special Forms. * dowhile: Special Forms. * encode: Miscellaneous. * envAdd: Environment Operations. * envNew: Environment Operations. * envThis: Environment Operations. * equal: Miscellaneous. * error <1>: Miscellaneous. * error: Command Reference. * eval: Miscellaneous. * fchdir: File Operations. * fclose: File Operations. * feof: File Operations. * fgets: File Operations. * fgetwd: File Operations. * fglob: File Operations. * fneweras: files.chh. * fopen: File Operations. * for: Special Forms. * foreach: Special Forms. * foreachkey: Special Forms. * fpipe: File Operations. * fputs: File Operations. * frest: files.chh. * fstat: File Operations. * fwholefile: files.chh. * hash: Hash Operations. * hcontains: Hash Operations. * hcount: Hash Operations. * hdelete: Hash Operations. * hkeys: Hash Operations. * if <1>: Special Forms. * if: Command Reference. * ifdef: Command Reference. * ifdefined: Command Reference. * ifndef: Command Reference. * ifnotdefined: Command Reference. * include: Command Reference. * lambda: Special Forms. * lappend: List Operations. * ldelete: List Operations. * let: Special Forms. * linsert: List Operations. * list: List Operations. * listIndexOf: list.chh. * listJoin: list.chh. * listLeftAccumulate: list.chh. * listMap: list.chh. * listRightAccumulate: list.chh. * listSearch: list.chh. * llength: List Operations. * locals: Special Forms. * lsort: List Operations. * luniq: List Operations. * not: Miscellaneous. * or: Special Forms. * outputenable: Miscellaneous. * random: Miscellaneous. * replacesubstring: strings.chh. * same: Miscellaneous. * schr: String Operations. * scmp: String Operations. * sgsub: String Operations. * shexdecode: Miscellaneous. * shexencode: Miscellaneous. * slength: String Operations. * smap: String Operations. * smatch: String Operations. * snumber: String Operations. * sqlClose: sql.chh. * sqlConnect: sql.chh. * sqlDatabaseInfo: sql.chh. * sqlQuery: sql.chh. * sqlResultColumnInfo: sql.chh. * sqlResultColumnNames: sql.chh. * sqlResultData: sql.chh. * sqlUpdate: sql.chh. * srange: String Operations. * sremovews: String Operations. * ssplit: String Operations. * ssub: String Operations. * stokenize: String Operations. * strneq: strings.chh. * timeFromString: time.chh. * timeHash2UNIX: Time Operations. * timeNow: time.chh. * timeToString: time.chh. * timeUNIX: Time Operations. * timeUNIX2Hash: Time Operations. * typeof: Miscellaneous. * until: Special Forms. * void: Miscellaneous. * w3image: w3lib.chh. * w3img: w3lib.chh. * w3imgHeight: w3lib.chh. * w3imgWidth: w3lib.chh. * w3imgX: w3lib.chh. * w3imgY: w3lib.chh. * w3rgbcolor: w3lib.chh. * warning: Miscellaneous. * while: Special Forms.