QR REPORT
QR REPORT ( {aTable ;} document {; methodName}{; *} )
Parameter | Type | Description | |
---|---|---|---|
aTable | Table | → | Table to use for the report, or Default table if omitted |
document | Text | → | Quick Report document to load |
methodName | Text | → | Name of method to call |
* | Operator | → | Deletion of printing dialog boxes |
This command is not thread-safe, it cannot be used in preemptive code.
Description
QR REPORT prints a report for aTable, created with the Quick Report editor. This editor allows users to create their own reports. For more information about creating reports with the Quick Report editor, refer to the Quick reports section of the 4D Design Reference manual.
Notes:
- The editor does not appear if the table has been declared “Invisible.”
- When the editor is called using the QR REPORT command, relations between tables keep their manual status, where applicable. This allows the developer to manage this status himself using the SET AUTOMATIC RELATIONS and SET FIELD RELATION command. However, keep in mind that automatic features are disabled when related tables are being viewed in a list form displayed using DISPLAY SELECTION, MODIFY SELECTION, or a subform. See Automatic and manual relations.
- The editor is called in an external window and it is not possible to use the QR ON COMMAND command in this context. However, you can use the methodName parameter to execute custom code when an interface command is activated (see below).
The document parameter is a report document that was created with the Quick Report editor and saved on disk. The document stores the specifications of the report, not the records to be printed.
If an empty string ("") is specified for document, QR REPORT displays an Open File dialog box and the user can select the report to print.
If the document parameter specifies a document that does not exist (for example, pass Char(1) in document), the Quick Report editor is displayed.
The methodName parameter designates a 4D project method that will be executed each time a document management command of the Quick Report editor is called by a user click on a button. Using this parameter is equivalent to using QR ON COMMAND in the context of the Quick Report editor window (QR ON COMMAND only works within the context of an included area). For example, you can use this parameter to change the character set used by the quick report. The methodName method receives two parameters:
Parameter | Type | Description | |||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
$1 | Longint | Area reference | |||||||||||||||||||||
$2 | Longint | Number of the command selected. To compare with the following constants of the QR Commands theme (only listed events are supported):
|
Note: If you want to compile your database, you must declare the $1 et $2 parameters explicitly as longints, even if you do not use them.
If you want to execute the initial command chosen by the user, use the following statement in the methodName method:
QR EXECUTE COMMAND($1;$2)
If the methodName parameter is an empty string ("") or is omitted, no method is called and the standard operation of QR REPORT is applied.
After a report is selected, the dialog boxes for printing are displayed, unless the * parameter is specified. If this parameter is specified, these dialog boxes are not displayed. The report is then printed.
If the Quick Report editor is not involved, the OK variable is set to 1 if a report is printed; otherwise, it is set to 0 (zero) (i.e., if the user clicked Cancel in the printing dialog boxes).
4D Server: This command can be executed on 4D Server within the framework of a stored procedure. In this context:
- Make sure that no dialog box appears on the server machine (except for a specific requirement). To do this, it is necessary to call the command with the * parameter.
- The syntax which makes the Quick Report editor appear does not work with 4D Server; in this case, the system variable OK is set to 0.
- In the case of a problem concerning the printer (out of paper, printer disconnected, etc.), no error message is generated.
Example 1
The following example lets the user query the [People] table, and then automatically prints the report “Detailed Listing”:
QUERY([People])
If(OK=1)
QR REPORT([People];"Detailed Listing";*)
End if
Example 2
The following example lets the user query the [People] table, and then lets the user choose which report to print:
QUERY([People])
If(OK=1)
QR REPORT([People];"")
End if
Example 3
The following example lets the user query the [People] table, and then displays the Quick Report editor so the user can design, save, load and print any reports:
QUERY([People])
If(OK=1)
QR REPORT([People];Char(1))
End if
Example 4
Refer to the example of the SET FIELD RELATION command.
Example 5
You want to convert the character set used in a quick report called using QR REPORT into Mac Roman:
QR REPORT([MyTable];Char(1);"myCallbackMeth")
The myCallbackMeth method converts the report when it is generated:
var $1;$2 : Integer
If($2=qr cmd generate) //if we generated a report
var $myblob : Blob
var $path;$text : Text
var $type : Integer
QR EXECUTE COMMAND($1;$2) //execution of command
QR GET DESTINATION($1;$type;$path) //retrieval of destination
If(($type=qr HTML file)|($type=qr text file))
DOCUMENT TO BLOB($path;$myblob)
//conversion to text using UTF-8
$text:=Convert to text($myblob;"UTF-8")
//use of MacRoman set
CONVERT FROM TEXT($text;"MacRoman";$myblob)
//Return of converted report
BLOB TO DOCUMENT($path;$myblob)
End if
Else //otherwise, execution of the command
QR EXECUTE COMMAND($1;$2)
End if