SetFld
Use this procedure/function to assign a value to a section field. Normally, this procedure is used to assign values to display only fields or to assign default values to fields which have not yet been edited.
Note |
DAL internally manages Unicode strings using UTF8, which is a standard mechanism for handling Unicode string data. The SetFld function will use this method if the field is defined with a Unicode font. See the Unicode Guide for more information. |
Syntax
SetFld (String, Field, Section, Form, Group)
Parameter |
Description |
String |
Enter a value appropriate for the field you are assigning. THe default is an empty string. |
Field |
Enter the name of a field. The default is the current field. |
Section |
Enter the name of a section that contains the field named. The default is the current section. |
Form |
Enter the name of a form that contains the section and/or field named. The default is the current form. |
Group |
Enter the name of the form group that contains the form, section, and/or field named. The default is the current group. |
The system returns one (1) if successful or zero (0) if the field cannot be changed or does not exist.
This procedure attempts to change the field's text each time the script executes. Therefore, use the SetFld procedure with discretion. Do not use the SetFld procedure if the script should not execute each time a user highlights a new field.
Notes
- A DAL script executes once during entry. A DAL calc executes each time the user highlights a new field. You make the DAL script or DAL calc designation in the Properties window.
- If you are using the SetFld procedure in a batch system execution and you are trying to set a field other than the one which initiated the rule, you must load the FAP file. To do so, add the CheckImageLoaded rule to the sections to which you plan to assign fields.
- Trailing spaces are deleted from the string to be stored. If you need the spaces, use a hard space (Alt + 0160). See the Rules Reference for more information about this rule.
Example
Here are some examples:
(Assume the section has three fields (First, Second, Third). The value of First is 123.)
Procedure |
Result |
Explanation |
SetFld( "N/A", "SECOND") |
1 |
Assume this script is associated with the field named First. When the user tabs from this field or highlights another field, the value of the field, Second is changed to N/A. |
IF ( !SetFld( 101, "MyField") ) "MyField", "not assigned!") END |
0 |
The IF statement determines whether or not the field MyField can be assigned the value "101". If not (meaning a field by that name does not exist or failed to accept the data), the message "Field MyField not assigned!" appears. |
SetFld( @( ), "MyField", , "FRM") |
1 or 0 |
This statement attempts to assign the value of the current field to MyField, located on the specified FRM. Since a section name was not given, the field may occur on any section on that form. |