Print Fields Buttons: Difference between revisions
(→Syntax) |
(→Syntax) |
||
Line 50: | Line 50: | ||
The Button's syntax is the same as the [[Print Fields]] syntax below. However, the [[Field Spec]] parameter must also include a '''B''' attribute followed by the desired FKEY value, as shown below. | The Button's syntax is the same as the [[Print Fields]] syntax below. However, the [[Field Spec]] parameter must also include a '''B''' attribute followed by the desired FKEY value, as shown below. | ||
[[image:Printfields.png]] | [[image:Printfields.png|800px]] | ||
[[image:Buttons.png]] | [[image:Buttons.png|700px]] | ||
===Parameters=== | ===Parameters=== |
Revision as of 18:11, 28 May 2013
Buttons can be added to your Business Rules! program to make user input more intuitive. Buttons are made by using the B attribute on a print fields statement. They set the FKEY value which then can be used to complete an action. Keep in mind that buttons depend on something being done within the program while BR waits for the button to be pushed by the user.
Comments and Examples
Here, the "Done" button is clicked after the user has selected the desired items. It sets FKEY to 99 and continues with to the program to WRITE a record to the file.
00340 print fields "23,30,CC 8,,b99" : "Done" 00350 do 00360 input fields "22,14,CHECK 8,,10;23,14,CHECK 8,,11;24,14,CHECK 8,,12": Box$(1),Box$(2),Box$(3) 00370 print fields "24,1,N 2": Fkey 00380 loop While Fkey~=99 00390 For I=1 to UDIM(box$) 00400 if box$(I)(1:1)="^" then ordered(I)=1 else ordered(I)=0 00410 next I
Line 340 prints the button. The DO LOOP on lines 350 to 380 give the button an action to wait for: printing the Check Boxes and waiting for them to be selected. The For/Next statements in lines 390 to 410 records which checkboxes were chosen.
In this example, the user can click "Yes" (which sets the FKEY value to 8 and displays the next record in the file, or "Quit", which sets the FKEY value to 9 and will end the program.
00011 open #1: "name=orders.INT, kfname=firstlast.int,kps=1,kln=60", internal, input, keyed 00012 print fields "17,2,c 15":"Next record?" 00013 print fields "18,2,cc 10,,b8":"Yes" 00014 print fields "18,14,cc 10,,b9":"Quit" 00015 ! 00016 read #1, using READFORM, search=Lastname$: First$,Last$,Address$,City$,State$,Zipcode$,Shipmethod$,Item1,Item2,Item3 00017 READFORM: form C 30,C 30,C 30,C 15,C 2,C 7,C 1,N 1,N 1,N 1 00018 print fields Mat Prinform$: "Name: ",First$," ",Last$,"Address: ",Address$,"City: ",City$,"State: ",State$,"Zipcode: ",Zipcode$ 00019 print fields Mat Prinform2$: "Overnight or Regular? ", Shipmethod$,"Item 1? ",Item1,"Item 2? ",Item2,"Item 3? ",Item3 00020 ! 00021 ! Prinform2: Form "11,2,c 22","11,25,c 1","13,2,c 8","13, 12,n 1","14,2,c 8","14,12,n 1","15,2,c 8","15,12,n 1" 00022 again: ! 00023 do 00024 input fields "24,1,c 1": nomatter$ 00025 loop until fkey=8 or fkey=9 00026 ! 00027 if FKEY=8 then 00028 read #1, using READFORM: First$,Last$,Address$,City$,State$,Zipcode$,Shipmethod$,Item1,Item2,Item3 00029 print fields Mat Prinform$: "Name: ",First$," ",Last$,"Address: ",Address$,"City: ",City$,"State: ",State$,"Zipcode: ",Zipcode$ 00030 print fields Mat Prinform2$: "Overnight or Regular? ", Shipmethod$,"Item 1? ",Item1,"Item 2? ",Item2,"Item 3? ",Item3 00031 goto again 00032 else end
Lines 13 and 14 print the buttons, then the DO LOOP in lines 23 to 25 wait for the user to click on one or the other. The "Yes" button returns control to the program in lines 27 to 31, while if FKEY equals 9 or anything else, it ends, on line 32.
Syntax
The Button's syntax is the same as the Print Fields syntax below. However, the Field Spec parameter must also include a B attribute followed by the desired FKEY value, as shown below.