Edit Fields Screen

These examples show how you can retrieve the contents of an edit field control from a default Edit Fields screen.

Example 1

To try this example, paste the following code onto the On Next event (before the Screen.Next action) of an Edit Fields screen. This event can be found on the Actions tab of the screen's properties.

-- Create an output string containing the text within the first edit field with the session variable %EditVar01%.
strOutputString1 = "The text in the first edit field is: "..SessionVar.Expand("%EditVar01%");

-- Create an output string containing the text within the second edit field with the session variable %EditVar02%.
strOutputString2 = "The text in the second edit field is: "..SessionVar.Expand("%EditVar02%");

-- Create an output string containing the text within the third edit field with the session variable %EditVar03%.
strOutputString3 = "The text in the third edit field is: "..SessionVar.Expand("%EditVar03%");

-- Display a dialog containing the four output strings displaying the values in each edit field.
Dialog.Message("Edit Fields", strOutputString1.."\r\n"..strOutputString2.."\r\n"..strOutputString3, MB_OK, MB_ICONINFORMATION, MB_DEFBUTTON1);

This action script demonstrates how to retrieve the text entered in an edit field, in this case, simply outputting it as a dialog message when you click the Next button.

Example 2

To try this example, paste the following code onto the On Next event of an Edit Fields screen and remove the Screen.Next() action that is there by default. This event can be found on the Actions tab of the screen's properties.

-- Check to make sure the first two edit fields are not empty.
if (SessionVar.Expand("%EditVar01%") == "") then
  -- Display a dialog notifying the user that the first edit field cannot be empty.
  Dialog.Message("Notice", "The first edit field cannot be empty. Please enter a value.", MB_OK, MB_ICONINFORMATION, MB_DEFBUTTON1);
  -- Set the input focus to the first edit field.
  Screen.SetFocus(CTRL_EDIT_01);
elseif (SessionVar.Expand("%EditVar02%") == "") then
  -- Display a dialog notifying the user that the second edit field cannot be empty.
  Dialog.Message("Notice", "The second edit field cannot be empty. Please enter a value.", MB_OK, MB_ICONINFORMATION, MB_DEFBUTTON1);
  -- Set the input focus to the second edit field.
  Screen.SetFocus(CTRL_EDIT_02);
else
  -- advance to the next screen
  Screen.Next();
end

This action script example illustrates how you can validate the contents of an edit field before proceeding in the update. The above script checks to make sure the first two edit fields on the screen are not empty, and prompts the user for input if they are. As you can see, other types of validation can easily be performed using this type of design.