HTBasic Help
×
Menu
Index

Example: Oven Control

 
10     ! *********************************************************************
20     ! Example: Oven Control
30     !
40     ! This program creates a METER widget and a SCROLLBAR widget.
50     ! As you set the SCROLLBAR bar, the associated value is
60     ! displayed on the METER widget. Note that the SCROLLBAR
70     ! value increases as the bar is moved from top to bottom.
80     !
90     ! ************************************************************
100   !
110   COM INTEGER Count,REAL Setpt
120   !
130   ! Create the widgets
140   !
150   ASSIGN @Main TO WIDGET "PANEL"
160   CONTROL @Main;SET ("X":100,"Y":50,"WIDTH":250,"HEIGHT":200)
170   CONTROL @Main;SET ("TITLE":" Example: Oven Control")
180   CONTROL @Main;SET ("SYSTEM MENU":"Quit")
190   !
200   ASSIGN @Disp1 TO WIDGET "METER";PARENT @Main
210   CONTROL @Disp1;SET ("X":5,"Y":5,"WIDTH":150,"HEIGHT":150)
220   CONTROL @Disp1;SET ("BACKGROUND":1)
230   !
240   ASSIGN @Inp TO WIDGET "SCROLLBAR";PARENT @Main
250   CONTROL @Inp;SET ("X":190,"Y":5,"WIDTH":20,"HEIGHT":150)
260   !
270   ! Set up the EVENT handlers
280   !
290   ON EVENT @Main,"SYSTEM MENU" GOTO Finis
300   ON EVENT @Inp,"DONE" GOSUB Serviceinp
310   ON EVENT @Inp,"CHANGED" GOSUB Serviceinp
320   !
330   ! Generate values
340   !
350   Setpt=50
360   Curtemp=0
370   Siz=2
380   !
390   CONTROL @Inp;SET ("VALUE":Setpt)
400   GOSUB Serviceinp
410   LOOP
420     Diff=Setpt-Curtemp
430     Noise=Siz*(RND-.5)*2
440     Delta=Diff/10+Noise
450     Curtemp=Curtemp+Delta
460     CONTROL @Disp1;SET ("VALUE":Curtemp)
470   END LOOP
480   !
490 Serviceinp:   !
500   STATUS @Inp;RETURN ("VALUE":Setpt)
510   Setpt=INT(Setpt)
520   RETURN
530   !
540 Finis:   !
550   ASSIGN @Main TO *                                ! Delete PANEL widget
560   END