Flat File Interface Language Environment

If you choose to use flat files (or plain-text files) as your data source, use the flat file interface (FFI) and its associated functions to open, close, read, write, and delete files on the Web server. The file language support uses FFI functions to read from or write to files on the Web server at the Web client's request through the browser. FFI views the file as a record file, each record equivalent to a row in a Net.Data macro table variable, and each value in a record equivalent to a field value in a Net.Data macro table variable. FFI reads records from a file into rows of a Net.Data macro table, and writes rows from a table into records.

See Net.Data Reference for description and syntax of the FFI built-in functions.

Configuring the FFI Language Environment

Verify that the following configuration statement is in the initialization file, on one line:

ENVIRONMENT (DTW_FILE)   DTWFILE   ( OUT RETURN_CODE )

See Environment Configuration Statements to learn more about the Net.Data initialization file and language environment ENVIRONMENT statements.

Calling FFI Built-in Functions

Call an FFI function as you would any other function. Use a DEFINE statement to define as variables any of the parameters that you want to pass; for example:

%DEFINE {
    myFile = "c:/private/myfile"
    myTable = %TABLE
    myWait = "1500"
    myRows = "2"
 %}
 

Then use a function call statement to invoke the function; for example:

@DTWF_UPDATE(myFile, "Delimited", "|", myTable, myWait, myRows)

Example

In this example, Net.Data reads the content of the ffi001.dat file into a Net.Data table and writes the content of this table into the tmp.dat file. Finally, Net.Data deletes the tmp.dat file.

%DEFINE {
mytable = %TABLE(ALL)
myfile  = "/usr/lpp/netdata/ffi//ffi001.dat"
tmpfile = "/usr/lpp/netdata/ffi/tmp.dat"
%}
%HTML(report) {
@DTWF_READ(myfile, "ASCIITEXT", " ", mytable)
@DTW_TB_TABLE(mytable)
 
@DTWF_WRITE(tmpfile, "ASCIITEXT", " ", mytable)
@DTW_TB_TABLE(mytable)
 
@DTWF_REMOVE(tmpfile)
%}


[ Top of Page | Previous Page | Next Page | Index ]