Xbasic

OBJECT.PREVIEW Function

Syntax

Output_Filename as C = :object_type.Preview(c layoutname [,c filter [,c order [,l modal [,l session_modal [, SQL::Arguments arguments [,* options ]]]]]])

Arguments

object_type

The type of object to preview. Can be one of the following:

  • "Browse"
  • "Form"
  • "Label"
  • "Letter"
  • "Report"
layoutname

The name of the layout to preview.

filter

Default = ".T." (All records). A character filter expression that evaluates to a logical value and selects records for the report.

order

Default = record order. A character order expression that sorts selected records.

modal

Default = .F.

.T. = The user cannot change focus without closing the dialog.

.F. = The user can change focus without closing the dialog.

session_modal

Default = .T.

.T. = This means that any script that calls the REPORT.PREVIEW() method will pause until the Print Preview window is closed. However, the preview window itself is not a modal dialog box. The user is free to select other windows in Alpha Anywhere.

.F. = The script does not pause until the Print Preview window is closed.

argumentsSQL::Arguments

Default = null_value(). Arguments that retrieve value(s) from variable(s) or prompts for value(s) at runtime. Only applicable to SQL Reports.

options

Default = null_value(). Sets filter (WHERE) and order (ORDER BY) expressions for a query against a passive-linked table. A pointer dot variable with 2 elements.

filterCharacter

Adds to the WHERE clause in the underlying SQL expression.

orderCharacter

Replaces the ORDER BY clause in the underlying SQL expression.

Description

Displays the Preview dialog box for the current layout.

Discussion

The <object>.preview() method displays the Preview dialog box showing the selected layout.

Example

This script previews the Invoice report with an argument. You can add as many arguments to the arguments collection as you want.

:Report.archive("Invoice")
DIM myargs as SQL::arguments
myargs.add("whatcity", "London") 

report.preview("report1", "", "", .f., .f., myargs)

Using the Options Argument

If you have a SQL report called "nw_customers" with the SQL Select statement select * from customers, you could use the following <object>.preview() statements:

Previews a report showing all of the customer records.
report.preview("Nw_customers")
Previews a report showing records for the city of London. Note: This method can be very slow for large databases.
report.preview("Nw_customers", "city = 'London'")

If the table had 1,000,000 records with 5 records for London, Alpha Anywhere would bring down all 1,000,000 records to the local computer and then do a filter on the table to get the 5 records to print.

Downloading 1,000,000 records and then post processing them with Alpha Anywhere can be very slow. It would be more efficient to do the filter as part of the SQL database query.

dim opt as P 
opt.filter = "city = 'London'" 
report.preview("nw_customers", "", "", .f., .f., null_value(), opt)

Note, that since opt is the last argument in the function prototype, you must supply values for all of the preceding arguments, even if they were optional arguments. If you do not have a value for the arguments parameter, you may pass in null_value() or a "dummy" SQL::Arguments object as shown in the example below:

dim opt as P 
dim dummyargs as SQL::arguments 
opt.filter = "city = 'London'"
report.preview("nw_customers", "", "", .f., .f., dummyargs, opt)

This example shows how to use the order property.

dim opt as P 
opt.filter = "city = 'London'" 
opt.order = "contactname, desc"

The filter argument is added to the existing SQL SELECT statement's WHERE clause. If the existing SQL SELECT statement was select * from customers where customertype = 'retail', and you specified options.filter = "city = 'London'", the actual SQL for the report would be select * from customers where customertype = 'retail' AND city = 'London'.

The order argument replaces any existing ORDER clause in the SQL statement. If the original sql statement was select * from customers order by city, and you set options.order to contactname, desc, region, the resulting SQL for the report will be select * from customers order by contactname, desc, region.

Limitations

Desktop applications only.

See Also