HTBasic Help
×
Menu
Index

Example: Combo Test

 
10     ! *********************************************************************
20     ! Example: COMBO Test
30     !
40     ! This program creates a COMBO widget and allows the
50     ! user to select an animal name from a defined list
60     ! of names or to enter a name from the keyboard. The
70     ! program displays an error message if the name entered
80     ! is not in the defined list.
90     !
100   ! ********************************************************
110   !
120   DIM L$(1:5)[26],S$[50]
130   INTEGER N
140   !
150   DATA " Aardvark"," Sidewinder"," Kiwi"," Pangolin"," Marmoset"
160   READ L$(*)
170   !
180   ASSIGN @Combo TO WIDGET "COMBO";SET ("SYSTEM MENU":"Quit")
190   CONTROL @Combo;SET ("TITLE":" Example: COMBO Test - Select an Animal")
200   CONTROL @Combo;SET ("BACKGROUND":1,"LIST BACKGROUND":1,"ITEMS":L$(*))
210   CONTROL @Combo;SET ("X":50,"Y":25,"WIDTH":325)
220   CONTROL @Combo;SET ("SYSTEM MENU":"Quit")
230   !
240   ON EVENT @Combo,"SELECTION" GOSUB Handler
250   ON EVENT @Combo,"RETURN" GOSUB Handler
260   ON EVENT @Combo,"SYSTEM MENU" GOTO Finis
270   !
280   LOOP
290     WAIT FOR EVENT
300   END LOOP
310   STOP
320      !
330 Handler:    !
340   STATUS @Combo;RETURN ("TEXT":S$)
350   FOR N=1 TO 5
360     IF S$=L$(N) THEN
370       S$="List item #"&VAL$(N)&": "&S$
380       DIALOG "INFORMATION",S$
390       RETURN
400     END IF
410   NEXT N
420   S$="Animal not in list: "&S$
430   DIALOG "ERROR",S$;SET ("TITLE":" Invalid Selection")
440   RETURN
450      !
460 Finis:    !
470   ASSIGN @Combo TO *                                ! Delete COMBO widget
480   END