Compatibility: Version 6.7.x, 6.8.x and 2003
This tech tip reviews the correct technique for passing a nil pointer parameter.
Recently I was working on a method to handle printing cross tab reports (using the new QR commands in 4D 2003). The specification called for a single generic method to handle the printing of a series of cross tab reports. One report was to summarize sales per quarter per state. Another report was to summarize sales per state per product category.
In order to handle the variety of reports and their formatting, a generic method, Rpt_QRCrsTabReports, was created. QRCrsTabReports required the passing of 13 parameters.
In the procedure call below, you can see the use of Rpt_QRCrsTabReports to generate a report of sales per quarter per state. Notice that generating a quarterly report requires the use of the 6th parameter to pass a pointer to a date field. Notice also, the use of the seventh parameter to pass the year for which the quarterly report will be done.
Rpt_QRCrsTabReports ("QuarterlySales";->[Invoices];"[Invoices]InvoiceDate";->[Customers]State;->[Invoices]InvoiceTotal;->[Invoices]InvoiceDate;"1998";"$^^^,^^0.00";"Grand Totals by Quarter";"Grand Totals by State";"4D Video Sales Report: Quarterly Sales Per State";1;"")
However, to use QRCrsTabReports to print a report that is not a quarterly report, say a report of sales per state per product category, the 6th parameter (the pointer the a date field) is not use, and neither is the sixth parameter, the year of a quarterly report.
Since the 6th parameter, the year of a quarterly report, is a string, passing a null value is easy done by passing a null string (""). But what about the 6th parameter, the pointer to a date field; how do you pass a nil pointer parameter? Simply leaving the parameter empty, or passing ->will generate a compiler error. Passing a nil pointer parameter is properly done, as shown below, by declaring a pointer variable, and then passing that variable as the parameter:
Rpt_QRCrsTabReports ("Sales";->[LineItems];"[Customers]State";->[Products]Category;->[LineItems]ExtendedPrice;$pNilPointer;"";"$^^^,^^0.00";"Grand Totals by State";"Grand Totals by Category";"4D Video Sales Report: Sales Per State Per Product Category";1;"")