PRINT operator
The PRINT operator creates an action that opens a form in print view.
Syntax
PRINT [executionType]
formSpec
[FILTERS fexpr1, ..., fexprM]
[printOptions]
formSpec takes one of the two forms below.
name [OBJECTS objName1 = expr1 [NULL], ..., objNameN = exprN [NULL]]
or:
classFormType className = expr [NULL]
printOptions takes one of the two forms below.
Message mode:
MESSAGE [syncType] [messageType]
[TOP topLimit] [OFFSET offsetLimit]
Interactive mode:
[format [SHEET sheetExpr] [PASSWORD passwordExpr] [TO filePropertyId]]
[previewMode]
[syncType]
[TO printerExpr]
Where topLimit and offsetLimit are each defined as:
limitExpr
or:
groupName1 = limitExpr1, ..., groupNameK = limitExprK
Description
The PRINT operator creates an action that opens the specified form in print view. In the OBJECTS block, equality filters on form objects are added; the FILTERS clause adds further filter expressions.
The operator has two top-level modes — the interactive mode (a preview window, direct printing, or export to a file) and the message mode (a popup message).
Parameters
-
nameForm name. Composite ID.
-
classFormTypeDetermines which form of the class is printed:
LIST— the class's list form.EDIT— the class's edit form.
-
classNameName of the user class whose list or edit form is printed. Composite ID.
-
executionTypeDetermines where the report is rendered and printed:
CLIENT— on the client. Used by default.SERVER— on the server. Meaningful only for the interactive mode and only when the report should reach a printer attached to the server.
-
objName1, ..., objNameNNames of form objects for which equality filter values are specified. Simple IDs.
-
expr, expr1, ..., exprNExpressions whose values determine the equality filter values for the corresponding form objects.
-
NULLSpecifies that the passed value may be
NULL. -
fexpr1, ..., fexprMFilter expressions added to the form.
Message mode options
-
MESSAGEKeyword selecting the message mode.
-
messageTypeSets how the message panel is rendered on the client:
LOG— message in theSystem.logwindow.INFO— informational message.SUCCESS— success message.WARN— warning message.ERROR— error message.DEFAULT— plain message. Used by default.
-
topLimit,offsetLimitNumber of leading rows shown/skipped respectively when rendering the message. Each is either a single value applied to every group object on the form, or a per-object-group map giving an individual value for the named group objects.
-
limitExpr,limitExpr1, ..., limitExprKExpressions whose values are the integer row limits or offsets.
-
groupName1, ..., groupNameKNames of group objects on the form whose limits or offsets are specified individually. Simple IDs.
Interactive mode options
-
formatSets the export format of the generated file:
PDF— exported to a PDF file.XLS,XLSX— exported to an Excel file.DOC,DOCX— exported to a Word file.RTF— exported to an RTF file.HTML— exported to an HTML file.
If omitted, no file is produced; the report is rendered through the interactive mode (see
previewModeandexecutionTypefor the resulting behavior). -
sheetExprExpression whose value is the sheet name in the resulting file. Used only with the
XLSandXLSXformats. -
passwordExprExpression whose value is the password that sets read-only protection on the resulting file. Used only with the
XLSandXLSXformats. -
filePropertyIdProperty ID to which the generated file is written. The property must have no parameters and its value must be of a file class. When given, the report is built on the server and the file is written to the property without any client interaction; otherwise the file is sent to the client and opened by the operating system. Has no effect with
SERVER(the report is sent directly to a server-side printer instead). May appear only whenformatis specified. -
previewModeSelects how the generated report is delivered on the client:
PREVIEW— the report is shown to the user (in a preview window, or opened in the OS-associated program whenformatis specified). Used by default.NOPREVIEW— the report is sent directly to the printer.
Has no effect with
SERVER. -
printerExprExpression whose value is the name of the target printer. If not specified, the default printer is used or the printer-selection dialog is offered, depending on the platform configuration.
Common options
-
syncTypeDetermines when the surrounding action continues:
WAIT— after the user closes the preview window or message on the client.NOWAIT— immediately after the form data has been prepared on the server. Used by default.
Has no effect with
SERVERor withTO filePropertyId.
Examples
FORM printOrder
OBJECTS o = Order
PROPERTIES(o) currency, customer
OBJECTS d = OrderDetail
PROPERTIES(d) idSku, price
FILTERS order(d) == o
;
print (Order o) {
PRINT printOrder OBJECTS o = o; // interactive preview
LOCAL file = FILE ();
PRINT printOrder OBJECTS o = o DOCX TO file; // write into a file property
open(file());
PRINT printOrder OBJECTS o = o XLS SHEET 'encrypted' PASSWORD 'pass'; // XLS with sheet name and password
PRINT LIST Order = o; // print the class's list form
PRINT printOrder OBJECTS o = o FILTERS price(d) > 100 MESSAGE WARN TOP 10; // top-10 high-price details as a warning message
}