You are here: Functions > FTYPE()

FTYPE()

FTYPE() returns a value to identify a type of field, variable or other project item. Use FTYPE() to test field, variable or other project item types when running a procedure.

Note: FTYPE() cannot be used on project items IF your primary table is server-based.

The field, variable or project item name should be entered as a quoted string.

Function Format

FTYPE(C,<type>)

If C is the name of a current field, the value returned is upper case “C”, “N”, “L” or “D”, indicating that the field is of character, numeric, logical or date type, respectively.

If C is a variable name, the value returned is lower case “c”, “n”, “l” or “d”, indicating that the variable is of character, numeric, logical or date type, respectively.

If C is the name of a procedure, “b” is returned. Similarly, FTYPE() returns “f” for a table layout (format), “w” for a workspace, “i” for an index and “r” for a View (report).

If C is none of the above, the value returned is “U” (Undefined).

If C is the specific name of a field, variable or project item ensure that you specify the name in matching single or double quotes.

If C is a variable containing the actual item name then specify the variable name without quotes.

If one or more of the field/variable or project item type designators (noted above) is included in the function as the TYPE parameter, only the named item of the specified types will be considered. If not found, the value returned is “U” (Undefined).

Examples

If Letter represents a character field and Number represents a numeric field:

FTYPE("Letter") = "C"

FTYPE("Number") = "N"

If you have a procedure that makes use of the Amount field for totaling purposes, you would want to ensure that there is an Amount field and that it is numeric before starting the procedure. To execute a procedure only if the Amount field exists and is a numeric field:

IF FTYPE("AMOUNT") = "N" DO STDAPP

Additionally, if a procedure makes use of a specific table layout (e.g. AR”) and you want to ensure the table layout exists before preceding in the procedure, you can test for the existence of the table layout using this function:

IF FTYPE("AR")="f" DO AR_Analysis

When a TYPE parameter is supplied, then only items of the specified type(s) will be considered. For example, if more than one project item (such as a view or a procedure) has the same name as a table layout, specify a TYPE parameter to ensure the correct project item (i.e. table layout) is processed:

IF FTYPE("AR","f")="f" OPEN AR_Analysis

Additionally, more than one TYPE parameter can be specified though it is rare that this would be done. Assuming a procedure exists named "Init":

FTYPE("Init", "CNLD")="U".

This is because no character, numeric, logical or date field exists with this name.

Note: When specifying TYPE parameters for fields or variables, the case of the type parameter(s) is irrelevant. For example entering C or c will find either a character field or variable. However, the resulting value returned from the FTYPE() function will always use the appropriate case so that you can ensure you are testing for the correct item.