90 ! This part of the program creates a panel with one menu selection.
100 ! Four menu buttons are put into the menu. When any of these menu
110 ! items is selected, an appropriate subroutine is called.
120 !
130 DIM Attr$(3)[15],Attr(3)
140 COM /Fgen/Freq,Ampl,Ampl_unit,Func,Offset,@Freq_disp,@Ampl_disp,@Offs_disp,@Func_disp,@Amplitude,@Am,@Pm
150 ASSIGN @Fgen_panel TO WIDGET "PANEL";SET ("TITLE":" Example: Function Generator","X":150,"Y":80,"WIDTH":240,"HEIGHT":200,"MAXIMIZABLE":0,"RESIZABLE":0)
160 CONTROL @Fgen_panel;SET ("SYSTEM MENU":"Quit")
170 ON EVENT @Fgen_panel,"SYSTEM MENU" GOTO Finis
180 !
190 ASSIGN @Fgen_main TO WIDGET "PULLDOWN MENU";SET ("LABEL":"Control Menu"),PARENT @Fgen_panel
200 ASSIGN @Frequency TO WIDGET "MENU BUTTON";SET ("LABEL":"Frequency"),PARENT @Fgen_main
210 ASSIGN @Amplitude TO WIDGET "MENU BUTTON";SET ("LABEL":"Amplitude"),PARENT @Fgen_main
220 ASSIGN @Dc_offset TO WIDGET "MENU BUTTON";SET ("LABEL":"DC Offset"),PARENT @Fgen_main
230 ASSIGN @Function TO WIDGET "MENU BUTTON";SET ("LABEL":"Function"),PARENT @Fgen_main
240 ASSIGN @Modulation TO WIDGET "CASCADE MENU";SET ("LABEL":"Modulation"),PARENT @Fgen_main
250 ASSIGN @Am TO WIDGET "MENU TOGGLE";SET ("LABEL":"AM"),PARENT @Modulation
260 ASSIGN @Pm TO WIDGET "MENU TOGGLE";SET ("LABEL":"PM"),PARENT @Modulation
270 !
280 ! Initial values for the controls
290 !
300 Freq=1000
310 Ampl=.001
320 Ampl_unit=0
330 Offset=0
340 Func=0
350 !
360 ! Displays for the values of the controls. The displays are actually
370 ! pushbuttons and the label for each button is used to display its
380 ! current value.
390 !
400 Attr$(0)="X"
410 Attr$(1)="Y"
420 Attr$(2)="WIDTH"
430 Attr$(3)="HEIGHT"
440 Attr(0)=30 ! X position
450 Attr(1)=8 ! Y position
460 Attr(2)=178 ! width
470 Attr(3)=33 ! height
480 !
490 ASSIGN @Freq_disp TO WIDGET "PUSHBUTTON";SET (Attr$(*):Attr(*),"LABEL":VAL$(Freq)&" Hz"),PARENT @Fgen_panel
500 Attr(1)=Attr(1)+Attr(3)
510 ASSIGN @Ampl_disp TO WIDGET "PUSHBUTTON";SET (Attr$(*):Attr(*),"LABEL":VAL$(Ampl)&" V p-p"),PARENT @Fgen_panel
520 Attr(1)=Attr(1)+Attr(3)
530 ASSIGN @Offs_disp TO WIDGET "PUSHBUTTON";SET (Attr$(*):Attr(*),"LABEL":VAL$(Offset)&" V offset"),PARENT @Fgen_panel
540 Attr(1)=Attr(1)+Attr(3)
550 ASSIGN @Func_disp TO WIDGET "PUSHBUTTON";SET (Attr$(*):Attr(*),"LABEL":"SINE"),PARENT @Fgen_panel
560 !
570 ! When either the menu is pulled down, or the display is clicked, call
580 ! a routine to change that control.
590 !
600 ON EVENT @Frequency,"ACTIVATED",1 CALL Set_frequency
610 ON EVENT @Function,"ACTIVATED",1 CALL Set_function
620 ON EVENT @Amplitude,"ACTIVATED",1 CALL Set_amplitude
630 ON EVENT @Dc_offset,"ACTIVATED",1 CALL Set_offset
640 ON EVENT @Freq_disp,"ACTIVATED",1 CALL Set_frequency
650 ON EVENT @Func_disp,"ACTIVATED",1 CALL Set_function
660 ON EVENT @Ampl_disp,"ACTIVATED",1 CALL Set_amplitude
670 ON EVENT @Offs_disp,"ACTIVATED",1 CALL Set_offset
680 !
690 ! Event handling for modulation toggles in the menu
700 !
710 ON EVENT @Am,"CHANGED",1 CALL Toggle_am
720 ON EVENT @Pm,"CHANGED",1 CALL Toggle_pm
730 !
740 LOOP
750 WAIT FOR EVENT
760 END LOOP
770 Finis: END
780 SUB Set_frequency
790 !
800 ! This routine sets the value of frequency.
810 !
820 COM /Fgen/Freq,Ampl,Ampl_unit,Func,Offset,@Freq_disp,@Ampl_disp,@Offs_disp,@Func_disp,@Amplitude,@Am,@Pm
830 !
840 ! The user is allowed to enter the new frequency in any of three units.
850 ! A cancel button is included in case the user makes a mistake.
860 !
870 DIM Btn$(3)[6],Freq$[20]
880 Btn$(0)="Hz"
890 Btn$(1)="kHz"
900 Btn$(2)="MHz"
910 Btn$(3)="Cancel"
920 !
930 ! Use a STRING dialog to get the new frequency. This dialog returns