| System Functions |
|
| Formats | 1.
Translation
Table in Program: TBL(string$,TBL=tbl_stmtref[,ERR=stmtref]) 2. Translation Table in Variable: TBL(string$,tbl_var$[,ERR=stmtref]) 3. Translate Using Position: TBL(position,expr_0[$],expr_1[$] ... ,expr_n[$][,ERR=stmtref]) 4. Character to Character Conversion : TBL(var$,compare$,table$) Where: |
|
| compare$ | String table to compare character by character with the value in | |
| var$. String expression. | ||
| expr_0[$] n List of expressions to be returned. Numeric or string expressions. Restriction: The expressions must all be the same type (i.e., all characters or all numerics). | ||
| position | Determines which expression to use. Positional or numeric expression, range 0 (zero) to n. | |
| stmtref | ||
| Program line number or statement label to which to transfer control. string$ | ||
| Table to use for conversion when a character in the compared value | ||
| matches the value in var$. String expression. | ||
| tbl_stmtref | Optional, if your table is embedded in the same statement as the TBL( )function. If you refer to a program tbl_stmtref, it must contain a conversion table. | |
| tbl_var$ | String variable. Contains conversion table to replace elements in the | |
| string$. String expression. | ||
| var$ | String variable. Contains a string to be translated or replaced. | |
| Returns | Converts string to values in table. | |
| Description | The TBL( ) function converts a string (all characters or all numeric) to the corresponding values set in a given translation table. | |
| See Also | Translation Tables in the ProvideX User's Guide | |
| Format 1 | Translation Table in
Program TBL(string$,TBL=tbl_stmtref[,ERR=stmtref]) Use this TBL( ) format if the translation table to convert the string$ is an embedded table in your program. If you include a tbl_stmtref, it must refer to a program statement containing a conversion table defined by a TABLE directive. This statement reference is optional if the conversion table is embedded in the same statement as the TBL( )function. For more information, refer to the TABLE Directive. |
|
| Format 2 | Translation Table in
Variable TBL(string$,tbl_var$[,ERR=stmtref]) Use this format if the translation table to convert the string$ is in a variable. |
|
| Format 3 | Translate Using
Position TBL(position,expr_0[$],expr_1[$] ... ,expr_n[$][,ERR=stmtref]) Use this format to obtain a value based on the numeric value of an expression. The value the TBL( ) function returns depends on the value of position. If it's 0 (zero), then the value of expr_0 will be returned, if 1, then expr_1 will be returned, and so on. |
|
| *Note* | The values for expr_0[$], expr_1[$], n[$] can be either string or numeric. The only requirement is the they must be all the same: all string or all numeric. | |
| Format 4 | Character to Character
Conversion
Use this format to do a character-to-character conversion of a string. ProvideX replaces each character in the string variable that matches a character in the first comparison string expression with the corresponding character from the table. That is, when a character in the string variable matches a character in compare$, then:
For example:
The above would replace all lower a,b, or c's with A, B, or C respectively. |
|
| Examples | Example 1:
In the above example the value in T$ is passed to a POS function to determine where in the string "DWM" it occurs. The POS function will return 1,2 or 3 based on which character it matches, or 0 if none. This value is then processed by the TBL function to return "???" for zero, or the appropriate text.
If EXP_DT$is null, the logical expression EXP_DT$=" " yields 1. A null date will print "Never". Otherwise, it yields 0 (zero) and the value of EXP_DT$ is printed. In effect, this form of TBL( ) becomes: TBL(logical_expr, else_value,true_value). Example 3:
This format of the TBL function replaces each character found in "ACF " with its corresponding character in "123_" |
|