Chapter 4.3: File Access
|[TOP] [UP] [PREV] [NEXT]|
The $file() function should only be used to include relatively short (a couple of lines, maximum) files, such as when you need to include the contents of a file in the middle of an HTML or SET string that you are building. Name is relative to the CML_Path directory specified in the swebd.conf file. (See the Caucus installation guide for details.)
If you need to include a large file, or one that contains CML directives, see the "include" directive in section 5.
The function evaluates to the full URL of the newly created file, thus making it possible to make the file immediately available on the Web in any subsequently produced HTML.
Range is one or more byte values or byte value ranges, expressed as decimal numbers. For example "32" is the decimal code for a "blank" character, and the range "65-90" covers the codes for the upper-case letters A through Z.
$file_data() evaluates to 1 if the first bytes characters of name are included in the range values, and 0 otherwise. Thus, for example, $file_data(name 500 32 65-90) would evaluate to 1 if the first 500 characters were either blanks or the letters A-Z, and 0 otherwise.
A good use of $file_data() is to determine if a file contains only "plain text", or is some other kind of file (word processor file, image file, etc.) If $file_data (name -1 9-26 32-126) is 1, name is most likely a text file.
The redirection takes effect on all quoted lines that follow the use of $output(). Another call to $output(), with no arguments, returns subsequent output from quoted lines to the browser, in effect "closing" the file.