An input field is a named value. You name it and you determine what it means by setting its value. The value is associated with the input field name. You can have several fields with the same name and they all display the same value. If the user edits one of them, they all change.
In this sample text, an input field for the customer’s name is repeated throughout:
Hello {customer}!
We know that you, {customer}, will be excited about our new deal. Please call soon, {customer}, and save money now.
In a script, you can set the value of the customer field:
rte_1.InputFieldChangeData("customer", "Mary")
Then the text would look like this:
Hello Mary!
We know that you, Mary, will be excited about our new deal. Please call soon, Mary, and save money now.
The user can also set the value. There are two methods:
Selecting it and typing a new value
Displaying the Input Field property sheet and editing the Data Value text box
Inserting input fields in a script The InputFieldInsert function inserts a field at the insertion point:
rtn = rte_1.InputFieldInsert("datafield")
In a rich text editing application, you might want the user to insert input fields. The user needs a way to specify the input field name.
In this example, the user selects a name from a ListBox containing possible input field names. The script inserts an input field at the insertion point using the selected name:
string ls_field integer rtn ls_field = lb_fields.SelectedItem() IF ls_field <> "" THEN rtn = rte_1.InputFieldInsert( ls_field ) IF rtn = -1 THEN MessageBox("Error", "Cannot insert field.") END IF ELSE MessageBox("No Selection", & "Please select an input field name.") END IF
To display a date or a page number in a printed document, you define an input field and set the input field’s value.
To include today’s date in the opening of a letter, you might:
Create an input field in the text. Name it anything you want.
In the script that opens the window or some other script, set the value of the input field to the current date.
For example, if the body of the letter included an input field called TODAY, you would write a script like the following to set it:
integer li_rtn li_rtn = rte_1.InputFieldChangeData( "today", & String(Today()) )
For information about setting page number values see “What the user sees”.