VA FileMan V. 22.0 Programmer Manual Banner


 

Main Chapter Getting Started Manual Advanced User Manual

ScreenMan Forms


Computed Fields

ScreenMan computed fields, like form-only fields, are fields that are defined only on the form. You cannot place computed fields from FileMan files on a form because the M code for those fields often directly references data in files, which is outside the context of ScreenMan's transaction.

When you define a ScreenMan computed field, you enter a Computed Expression. The computed expression has the following format:

M code that sets the local variable Y

For example:

    S:$D(FLAG) Y=$P(MYVAR,",",2)_" "_$P(MYVAR,",")

The computed expression can reference data dictionary fields, form-only fields, and computed fields used elsewhere on the form. If the user changes the value of a field used in a computed expression, ScreenMan automatically recalculates and repaints the computed field.

The expression atom that identifies other form elements has a syntax that uses curly braces ({}) as described below.

Referencing Data Dictionary Fields

In the formats below, "Field" is the name or number of a data dictionary field. "Pfield" is the name or number of a pointer-type data dictionary field. "File" is the name or number of a file.

Syntax for Computed Expression Atom that References a DD Field
Format Explanation
{Field;Opt_spec} The value of Field is retrieved.

An Opt_spec (optional specifier) can be used to retrieve the internal, rather than the external form:

;I Retrieve the Internal form of the Field value.
{Pfield:Field;Opt_spec} Pfield is a pointer to a file. The value of Field in that file is retrieved. The Opt_spec value of ;I can be used as described immediately above to retrieve the internal, rather than the external form.
{Field_1;Opt_spec1: File:Field_2;Opt_spec} Field_1 is not a pointer field. The value of Field_1 is used to do a lookup into File. Field_2 from that file is retrieved.

An Opt_spec value of ;I can be used to retrieve the internal rather than the external form.

In addition, you can control how the lookup is done by using any of the following optional specifiers for Opt_spec1:

;I Use the Internal form of the field value for the lookup
;IX(xref list) Use specific IndeX(es) in the lookup. (For example ;IX(B^C) specifies that the B and C index should be used.) If this specifier is not used, all indexes starting with the B index are used in the lookup.
Referencing Form-Only and Computed Fields

A computed expression atom can also reference form-only fields and computed fields used on the form.

In the formats below, the syntax is similar to the that for referencing data dictionary fields, except that "FO(Form_only)" is used instead of "Field." "Form_only" is a three-piece comma-delimited string that identifies a form-only or computed field. See the description of Syntax for Pointer Link -- Navigating Via Form-only Fields for a description of the format of "Form_only."

Syntax for Computed Expression Atom that References a Form-only Field
Format Explanation
{FO(Form_only);Opt_spec} The value of Form_only is retrieved.

An Opt_spec (optional specifier) can be used to retrieve the internal, rather than the external form.

;I Retrieve the Internal form of the Form_only field.
{FO(Pform_only: Field;Opt_spec} Pfield_order is a pointer-type form-only field that points to a file. The value of Field in that file is retrieved.

The Opt_spec value of ;I can be used as described above to retrieve the internal, rather than the external form.

{FO(Form_only);Opt_spec1 :File:Field_2;Opt_spec} Form_only is a form-only field that is not a pointer-type form-only field. The value of Field_order is used to do a lookup into File. Field_2 from that file is retrieved.

An Opt_spec value of ;I can be used to retrieve the internal, rather than the external form.

In addition, you can control how the lookup is done by using any of the following optional specifiers for Opt_spec1:

;I Use the Internal form of the field value for the lookup
;IX(xref list) Use specific IndeX(es) in the lookup. (For example ;IX(B^C) specifies that the B and C index should be used.) If this specifier is not used, all indexes starting with the B index are used in the lookup.
Examples
    S Y="The value is: "_{NUMERIC}
    S:$D(var)#2 Y="The value is: "_{NUMERIC}
    S Y={LAST NAME}_","_{FIRST NAME}
    S Y={NAME}_" "_{NAME:SSN}
    S Y={FO(PRICE)}*1.085
    S Y={FO(NAME):NEW PERSON:SSN}

 


Reviewed/Updated: March 10, 2007