Print Fields Buttons: Difference between revisions
(→Syntax) |
No edit summary |
||
Line 110: | Line 110: | ||
:2.) When [[Option (Config)|OPTION]] INVP is in effect, the normal printing of commas and periods is interchanged in PIC, N, NZ, L, G and GZ [[format specifications]] to produce European-style numbers. | :2.) When [[Option (Config)|OPTION]] INVP is in effect, the normal printing of commas and periods is interchanged in PIC, N, NZ, L, G and GZ [[format specifications]] to produce European-style numbers. | ||
:3.) See [[Functions]] for information about [[CNT]], which applies to errors in field definition arrays used in full screen processing. | :3.) See [[Functions]] for information about [[CNT]], which applies to errors in field definition arrays used in full screen processing. | ||
<noinclude> | |||
[[Category:GUI]] | |||
</noinclude> |
Revision as of 16:58, 13 July 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.
- Print Fields Syntax
- Field Spec parameter for buttons
Parameters
- Print Fields Parameters
The "#wind-num" parameter represents the file number of a window which has already been opened by an OPEN window statement. When this parameter is used, Business Rules! inputs to and outputs from the window as if it were a separate screen: the first row and column of the window are considered row 1 and column 1.
"FIELDS" is a required keyword which signals that data is to be printed to specific fields on the screen. It must be followed by one of three possible parameters, each of which defines the fields to be used for input.
The "MAT string-array" parameter indicates that multiple field definitions are located in the specified string array. The array must contain all the same elements that are identified in the "field-spec" parameter.
The "string expression" parameter may also be used to define the input fields, but its value must also contain all the same elements that are identified in the "field-spec" parameter.
The "field-spec" parameter represents a separate syntax (see below) that identifies the following for each input field: row number; column number; format type, length and fraction length (if required) of the data to be input; and the monochrome and/or color attributes which are to be used for the field (control attributes are ignored), in this case B gives the field its "button" look.
See Format Specifications and File I/O for information about the format specifications which may be used with the PRINT FIELDS statement.
After the required colon, at least one "data-item" or "MAT array-name" is required. These two parameters represent the words which will display on the button. Multiple variables must be separated by commas.
PRINT FIELDS provides error processing with the optional "error-cond line-ref" parameter. See Error Conditions for more information.
- Field Spec Parameters
If the "string-expr" or "MAT string-array" parameters are used to specify the Field Spec definition, each must include the same elements identified below:
The "row" parameter is a required integer value that indicates the row number on the screen or in the window where the data is to be entered.
The "column" parameter is a required integer value that indicates the starting column number on the screen where data is to be entered.
The next set of parameters specifies the format type of the data to be entered. There are three possible routes. In the top route, "form-spec" represents either a numeric or string format specification. G, GL, GU, GZ, L, N, and NZ are all valid in this position for numeric fields; C, CC, CR, CL, CU, G, GL, GU, GZ, V, VL and VU are all valid in this position for string fields. The specification must be followed by a space.
The "field-length" parameter, which is an integer value that identifies the length (including decimal point and decimal positions) of the field, comes next. If the field contains decimal positions, "fraction" should identify how many there are; this parameter must be separated from the field length by a period (no spaces).
See Field specifications and Format specifications for additional information about all the format specifications listed in this section.
The "attributes" parameter represents an insertable syntax that identifies the appearance and control attributes that are to be used for the field. See Attributes in Definitions for the insertable syntax and additional information.
"B" will give the field it's button appearance and the following FKEY number will set the value which initiates the button's action. For example:
00050 print fields "10,5,cc 10,,b9":"Quit"
Will set the FKEY value to 9.
Defaults
- 1.) Output to the full screen (not a window).
- 2.) Interrupt the program if an error occurs and "ON error" is not active.
- 3.) Fraction length=0.
- 4.) Maximum DIM length.
- 5.) Use current attributes.
Technical Considerations
- 1.) Relevant error conditions are: CONV, ERROR, EXIT, HELP, IOERR, and SOFLOW.
- 2.) When OPTION INVP is in effect, the normal printing of commas and periods is interchanged in PIC, N, NZ, L, G and GZ format specifications to produce European-style numbers.
- 3.) See Functions for information about CNT, which applies to errors in field definition arrays used in full screen processing.