5 Controlling Forms

Example Program

When this program is run, it displays a form and asks the user to fill it in. When ENTER is pressed, the program checks that the zip code, area code and phone fields have been filled in with numbers. If not, the program resets the cursor and asks that the field be re-entered. The program uses a form that looks as follows:

10  !    The form is stored in file "NEWCUS".
20  !    The input fields are name, address and phone.
30  !    The output field is account.
40  !    The customer information is stored in a file called "CUSTMR"
50  !    The first record contains the next account number to be used.
60  !
70  !    Begin program
80  !
90       OPTION BASE 1
100      DIM A$(10)[20],B$[80],C$[200]
110      ASSIGN #1 TO "CUSTMR,FILES"
120 !
130      GET FORM "NEWCUS,FILES"
140 !
150 Input: INPUT
160      IF TFNUM%<>9 THEN GOTO 150
170          ENTER A$(*)
180 !
190 A:   IF (A$(7)>"99999") OR (A$(7)%<"00000") THEN GOTO Zip
200 B:   IF (A$(8)>"999") OR (A$(8)%<"000") THEN GOTO Area
210 C:   IF (A$(9)>"9999999") OR (A$(9)%<"0000000") THEN GOTO Phone
220 !
230      READ #1,1;Acc
240      PRINT Acc
250      B=Acc+1
260      PRINT #1,1;B
270      A$(10)=VAL$(Acc)
280 !
290      FOR I=1 TO 10
300        C$=C$+A$(I)
310      NEXT I
320 !
330      PRINT #1,B;C$
340      LDISP "DO YOU WANT TO ADD ANOTHER CUSTOMER?"
350      LINPUT B$
360 !
370      IF (B$[1]%<"Y") OR (B$[1]>"Y") THEN GOTO End
380 !
390      C$=" "
400      CLEAR FORM
410      GOTO Input
420 !
430 Zip: LDISP "YOU HAVE ENTERED AN INCORRECT ZIP CODE. PLEASE RE-ENTER."
440      CURSOR IF#1,CF#7
450      GOTO Input
480 !
490 Area: LDISP "YOU HAVE ENTERED AN INCORRECT AREA CODE. PLEASE RE-ENTER."
500      CURSOR IF#1,CF#8
510      GOTO Input
540 !
550 Phone: LDISP "YOU HAVE ENTERED AN INCORRECT PHONE NUMBER."
560      LDISP "PLEASE RE-ENTER"
570      CURSOR IF#1,CF#9
580      GOTO Input
610 !
620 !    End of program
630 !
640 End: EXIT FORM
650      ASSIGN #1 TO *
660      END

Eloquence Forms Manual - 19 DEC 2002