Reprpl V 2.0
The Comet Reporter string replacement pre-processor
REPRPL makes it easy for
an operator to enter values into an existing Reporter specification. With Version
2 a programmer can insert values dynamically. Version 2 adds a new kind of
replacement variable, the # variable. The definition line for the # variable
names an ENTER program and the ENTER program returns the value that is then
inserted into the Reporter specification.
The
# variable was added with the thought that it could be used to identify files
whose name is a concatenation of the actual file names and a company code
prefix. In an Internet Basic program, these files are Opened with code like:
FLNM$
= ZZCO$ + “C1A” & Open (1) FLNM$
but clearly it could be used for other
purposes as well. For example an entire date selection string could be
developed in an ENTER program and inserted into a report specification.
The Comet Reporter is a great tool for ad hoc reports. Show me all the invoices for customers AA0100, AA0200 and AA0300 that were posted in January 2001. It's easy to write the report:
INPUT RECEIVABLES (MAR1)
TITLE RECEIVABLES FOR CUSTOMERS AA0100 TO AA0200
TITLE WITH INVOICES DATES BETWEEN 01/01/01 TO 01/31/01
PRINTER LP1
KEYRANGE "AA0100" TO "AA0300"
REPORT
DEFINE STINV.DATE.SEQ = DATE2NUM("01/01/04",0);6.0
DEFINE ENINV.DATE.SEQ = DATE2NUM("01/31/04",0);6.0
SELECTING IF AR.DATE.SEQ GE STINV.DATE.SEQ AND
AR.DATE.SEQ LE ENINV.DATE.SEQ
USING R1.TO.C1A (MAC1A)
PRINT YADA, YADA, YADA
The Reporter is fine if you're a geeky nerd, but it is problematic when you need to re-use a report again and again selecting different customers, different time periods and, perhaps, printing to a different printer. REPRPL was written to address this limitation. Here's the same report revised so that REPRPL can do its string replacement thing:
%0 This string will appear on line 0 of the prompt entry screen
%1 03 Printer name [LP2]
%2 06 Starting customer number
%3 06 Ending customer number
%4 08 Starting invoice date [01/01/04]
%5 08 Ending invoice date
%# ENTER GETZZCO
INPUT RECEIVABLES (%#R1)
TITLE RECEIVABLES FOR CUSTOMERS %2 TO %3
TITLE WITH INVOICES DATES BETWEEN %4 TO %5
PRINTER %1
KEYRANGE "%2" TO "%3"
REPORT
DEFINE STINV.DATE.SEQ = DATE2NUM("%4",0);6.0
DEFINE ENINV.DATE.SEQ = DATE2NUM("%5",0);6.0
SELECTING IF AR.DATE.SEQ GE STINV.DATE.SEQ AND
AR.DATE.SEQ LE ENINV.DATE.SEQ
USING R1.TO.C1A (%#C1A)
PRINT YADA, YADA, YADA
You run REPRPL and pass it the name of the report specification file in common. REPRPL prompts the operator for the values to be inserted into the report specs using the prompt strings you provide in the token replacement definition lines that precede the report specs. It copies the specification to a temporary file, inserts the operator's responses as specified, and passes the updated temporary spec file onto the Reporter.
The format of the replacement string lines are:
· a % in column 1,
· a number from 1 to 9 in column 2 (in proper numeric sequence),
· a space,
· two bytes defining the size of the replacement string,
· a space,
· a free form prompt string of up to 40 bytes in length
· an optional default value which must be enclosed in square brackets, [01/01/00]
Version 2 now includes the %#
specification line. The only value in the %# line is the name of an ENTER
program. That custom program returns a value in the system buffer and REPRPL
inserts that string into the Reporter specification.
Comments, Remarks, Suggestions
Two points: REPRPL recognizes %0 to %9 and %# only, and if you need a percent sign followed by a number as a literal in your report specification, this program will not perform properly.
There is provision for only one %#
replacement string and I could see no value in coding for a default value in
the %# line.
The length of the string replacement
variable is currently 20 bytes.
REPRPL does not “know” if the variable
in question is a date so there is no date validation in REPRPL. The source is
included for anyone who wants to add that function.