IBM Books

Administration and Programming Guide for OS/400

Calling Net.Data Built-in Functions

Net.Data provides a large set of built-in functions to simplify Web page development. These functions are already defined by Net.Data, so you do not need to define them. You can call these functions as you would call other functions.

Figure 7 shows how the Net.Data built-in functions and the macro interact.

Figure 7. Net.Data Built-in Functions



Net.Data Built-in Functions

Built-in functions can return their results in three ways, depending on its prefix:

Some built-in functions do not have each type. To determine which type a particular built-in function has, see the Net.Data built-in functions chapter in Net.Data Reference.

The following sections provide a high-level overview of the Net.Data built-in functions. Use these functions to perform general purpose, math, string, word, or table manipulation functions. Additionally, you can use persistent functions for transaction processing. See Net.Data Reference for descriptions of each function with syntax and examples. Some of these functions required variables to be set prior to their use, or must be used in a specific context. Not all operating systems support each built-in function. See Net.Data Reference to determine which functions are supported for your operating system.

General Purpose Functions

This set of functions help you develop Web pages by altering data or accessing system services. You can use them to send mail, process HTTP cookies, generate HTML escape codes, and get other useful information from the system.

For example, to specify that Net.Data should exit a macro if a specific condition occurs, without processing the rest of the macro, you use the DTW_EXIT function:

%HTML(cache_example) {
 
<html>
 <head>
 <title>This is the page title</title>
 </head>
 <body>
 <center>
 <h3>This is the Main Heading</h3>
 <!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!>
 <! Joe Smith sees a very short page                   !>
 <!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!>
 %IF (customer == "Joe Smith")
</body>
</html>
 
@DTW_EXIT()
 
%ENDIF
 
...
 
</body>
 </html>
 %}

Another useful function is the DTW_URLESCSEQ function, which replaces characters that are not allowed in a URL with their escape values. For example, if the input variable string1 equals "Guys & Dolls", DTW_URLESCSEQ assigns the output variable to the value "Guys%20%26%20Dolls".

See the built-in functions chapter in Net.Data Reference for a list of valid general functions with syntax and examples.

Math Functions

These functions perform mathematical operations, letting you calculate or alter numeric data. Besides standard mathematical operations, you can also perform modulus division, specify a result precision, and use scientific notation.

For example, the function DTW_POWER raises the value of its first parameter to the power of its second parameter and returns the result, as shown in the following example:

@DTW_POWER("2", "-3", result)

DTW_POWER returns ".125" in the variable result

See the built-in functions chapter in Net.Data Reference for a list of valid math functions with syntax and examples.

String Functions

These functions let you manipulate characters within strings. You can change a string's case, insert or delete characters, assign a string value to another variable, plus other useful functions.

For example, you can use DTW_ASSIGN to assign the value of an input variable to an output variable. You can also use this function to change a variable in a macro. In the following example, the variable RC is assigned to zero.

@DTW_ASSIGN(RC, "0")

Other string functions include DTW_CONCAT, which concatenates strings, and DTW_INSERT, which inserts strings at a specific position, as well many other string manipulations functions.

See the built-in functions chapter in Net.Data Reference for a list of valid string functions with syntax and examples.

Word Functions

These functions let you manipulate words in character strings. Most of these functions work similar to string functions, but on entire words. For example, they let you count the number of words in a string, remove words, search a string for a word.

For example, use DTW_DELW0RD to delete a specified number of words from a string:

@DTW_DELWORD("Now is the time", "2", "2", result)

DTW_DELWORD returns the string "Now time".

Other word functions include DTW_WORDLENGTH, which returns the number of characters in a word, and DTW_WORDPOS, which returns the position of a word within a string.

See the built-in functions chapter in Net.Data Reference for a list of valid word functions with syntax and examples.

Table Functions

You can use these functions to generate reports or forms using the data in a Net.Data table variable. You can also use these functions to create Net.Data tables, and to manipulate and retrieve values in those tables. Table variables contain a set of values and their associated column names. They provide a convenient way to pass groups of values to a function.

For example, DTW_TB_APPENDROW appends a row to the table. In the following example, Net.Data appends ten rows to the table, myTable:

@DTW_TB_APPENDROW(myTable, "10")

Additionally, DTW_TB_DUMPH, returns the contents of a macro table variable, enclosed in <PRE></PRE> tags, with each row of the table is displayed on a different line. And DTW_TB_CHECKBOX returns one or more HTML check box input tags from a macro table variable.

See the built-in functions chapter in Net.Data Reference for a list of valid table functions with syntax and examples.

Flat File Functions

Use the flat file interface (FFI) functions to open, read, and manipulate data from flat file sources (text files), as well as store data in flat files.

For example, DTWF_APPEND, writes the contents of a table variable to the end of a file, and DTWF_DELETE deletes records from a file.

Additionally, the FFI functions allow file locking with DTWF_CLOSE and DTWF_OPEN. DTWF_OPEN locks a file that so that another request cannot read or update the file. DTWF_CLOSE releases the file when Net.Data is done with it, allowing other requests to access the file.


See the built-in functions chapter in Net.Data Reference for a list of valid FFI functions with syntax and examples.

Web Registry Functions

Use the Web registry functions to maintain registries and the entries they contain. A Web registry is a file with a key maintained by Net.Data to allow you to add, retrieve, and delete entries easily.

For example, DTWR_ADDENTRY adds entries, while DTWR_DELENTRY deletes entries. DTWR_LISTSUB returns information about the registry entries in an OUT table parameter, and DTWR_UPDATEENTRY replaces the existing values for a specified registry entry with a new value.

See the built-in functions chapter in Net.Data Reference for a list of valid Web registry functions with syntax and examples.

Persistent Functions

The persistent macro functions support transaction processing in Net.Data by helping you define which macro blocks are persistent within a single transaction. Use these functions to define the start and end of a transaction, which HTML blocks are persistent throughout the transaction, the scope of the variables within the transaction, and whether to commit or rollback changes within the transaction.

For example, DTW_ACCEPT identifies the transaction handle for a transaction, while DTW_TERMINATE identifies the final HTML block in the transaction. DTW_RTVHANDLE generates a unique transaction handle for blocks in the transaction. You can use DTW_COMMIT and DTW_ROLLBACK to initiate commits and rollbacks during the transaction.

See Transaction Management with Persistent Macros for more information. Also see the built-in functions chapter in Net.Data Reference for a list of valid persistent functions with syntax and examples.


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