1 / 12

Interactive Scripts: Intermediate

Interactive Scripts: Intermediate. Error Trapping.

vivi
Download Presentation

Interactive Scripts: Intermediate

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Interactive Scripts:Intermediate

  2. Error Trapping When requesting user input, it is imperative that the users enter the data in the desired format. Dropdown, radio buttons, and check boxes provide the user with limited options. The Edit Box and ACCEPT() Commands, however, allow the users to enter data in a free flow manner. Entering invalid data can cause the script to crash or produce invalid results. In order to avoid this, users should engage in a practice known as Error Trapping.

  3. The Error Trapping Principle The way an error trap works is that it will repeat a script until the conditions for acceptable data are met. This generally means: • Define a flag to monitor the conditions. • Execute a subscript so long as the conditions are not met. • At the end of the subscript, check to see if the conditions are met. If they are, then change the flag ending the script.

  4. Example 1: While writing a script, you wish to ask the user for a minimum dollar amount. You only want numerics, a maximum of one period, and negative signs.

  5. Script ASSIGN v_flag = F DO subscript WHILE v_flag = F

  6. Subscript V_flag = T ACCEPT "Enter minimum amount" TO v_minimum COM If the value entered contains anything other than a COM numeric/negative sign/period then the flag will be set to zero COM causing the subscript to be rerun and the script to pause with a COM message to the user explaining what the problem is. IF EXCLUDE(v_minimum, "0123456789- .") <> " " and OCCURS(v_minimum, ". ")<=1 ASSIGN v_flag = F IF v_flag = F PAUSE “Please use only numbers, periods, and negative signs.”

  7. Lists Using one of the methods described above, you’ve created a list. Using this list, you want to plug it into a dropdown box asking the user to select a value. This is very easy to accomplish. As dialogue boxes can be complex to write, it is often easiest to use the ACL Dialogue Wizard to write the skeleton for your script.

  8. Dialogue script list: DIALOG (DIALOG TITLE "User Dialog" WIDTH 494 HEIGHT 159 ) (BUTTONSET TITLE "&OK;&Cancel" AT 370 12 DEFAULT 1 ) (DROPDOWN TITLE "variable1;variable2;variable3" TO "DROPDOWN1" AT 24 84 DEFAULT 2 ) (TEXT TITLE "test" AT 24 52 )

  9. Dialog Command broken down: • DIALOG ---Invokes the Dialog Command • (DIALOG TITLE "User Dialog" WIDTH 494 HEIGHT 159 ) ---Defines the width and height of dialog box. • (BUTTONSET TITLE "&OK;&Cancel" AT 370 12 DEFAULT 1 ) ---Positions the “OK/Cancel” button at position over 370 spaces and down 12. • (DROPDOWN TITLE "variable1;variable2;variable3" ---this is the list of items within the dropdown list. • TO "DROPDOWN1" ---The default variable name assigned by ACL. • AT 24 84 ---Locates the drop down at 24 over and 84 down. • DEFAULT 2 ) ---Defines the default value as the second value in the list. A field does not require a DEFAULT value. • (TEXT TITLE "test" AT 24 52 ) ---Locates text at position 24 over and 52 down.

  10. Dialog Script project item • DIALOG ---Invokes the Dialog Command • (DIALOG TITLE "User Dialog" WIDTH 459 HEIGHT 159 ) ---Defines the width and height of dialog box. • (BUTTONSET TITLE "&OK;&Cancel" AT 370 12 DEFAULT 1 ) ---Positions the “OK/Cancel” button at position over 370 spaces and down 12. • (ITEM TITLE "NCD" ---NCD indicates that the dropdown box will include “N”umerics, “C”haracter” and “D”ate fields. • TO "ITEM1" ---Item1 is the default variable name assigned by ACL. • AT 48 60 WIDTH 255 ---The dropdown will appear 48 spaces over and 60 down with a width of 255. • DEFAULT "test" ) ---The default value will be “test.”

  11. Data Normalization When using interactive scripts, it is often necessary to normalize the data to ensure accurate data analysis. This can concern both the data contained within the field and the description of the field itself.

  12. Modifying Data in Fields Often times in order to perform an analysis, the data must be normalized within the fields themselves. The use of functions such as UPPER() or ALLTRIM() commands is much more important with interactive scripts than it is with non-interactive scripts.

More Related