Introduction
This program is a command line utility for extracting data from a report and
sending it to a text file. It allows you to make use of coumputed expressions and groups.
It was originally written to help write text files that contain columns in a fixed width format.
dw2file_fun.pbd
must also be in the same directory if you call any of
the functions described at the bottom of this file.
The arguments for
dw2file.exe
are
-f filename
Output filename
dw2file_output.txt is used if omitted.
-r1 report
Main report name found in or dw2file_rep.pbd
-r2 report
Secondary report name found in dw2file_rep.pbd
This is appended to output file.
-d Set Debug mode
This outputs details in the syserr.log file
-s Set Silent mode
This stops showing message boxes, but still writes to syserr.log
-a Append data to filename
-a1 arg1 arg2
Up to 10 Retrieval arguments for main report (not including session id).
All arguments are treated as strings.
-a2 arg1 arg2
Up to 10 Retrieval arguments for secondary report (not including session id).
All arguments are treated as strings.
-q Enable processing of SQL computed fields.
Note:
switch characters are not case sensitive.
So -F is the same as -f.
Spaces in arguments should be enclosed in quotes
The order of switches is not important.
All errors are logged to the syserr.log file and serious errors are shown in a
message box.
Examples
dw2file -r1 r_sample_report -f pba.txt
dw2file -r1 r_sample_report -a sad sdf -f pba.txt -d
dw2file -r1 r_part_summary -f out.txt -a enc-side -
dw2file -r1 r_ass_parts -f out.txt -a1 "enc-side" "-" -r2 r_part_ops -a2 enc-side -
Report Definition
Prompt for criteria can be used to filter the report at run time.
Inside the report you need to assign special column names to data or computed fields
and the program will extract these.
The special names are
Output once at the top of the file.
output_header
Output before group
output_group1_header
output_group2_header
output_group3_header
Output for each row.
output_detail
Output after group
output_group1_footer
output_group2_footer
output_group3_footer
Output once at the bottom of the file.
output_footer
All column names are optional.
New line in the output file can be added by using "
~r~n
"
in the expression.
e.g.
cat_code + "~r~n" + cat_type
You can also add special computed expressions that can
contain an SQL statement.
They are
Process SQL once at the top of the file.
output_header_sql
Process SQL before group
output_group1_header_sql
Process SQL for each row.
output_detail_sql
Process SQL after group
output_group1_footer_sql
Process SQL once at the bottom of the file.
output_footer_sql
WARNING: be very careful when updating you database
in this way as it cause problems. Use the debug flag
the thoroughly check the statements and only enable the
SQL when you are absolutely sure that they are correct.
A typical SQL update command could be something like
output_detail_sql
"UPDATE invoices SET inv_status = 'ACC', status_date = today WHERE invoices.inv_id = " + String(inv_id) + ";"
Note:
Use single quotes in SQL for enclosing strings
The retrieval arguments are all passed as strings and
must be defined in the report as such. When using them in the
SQL as comparisons you may have to convert them to a
number or date.
Convert to a number CAST( arg AS DECIMAL )
Convert to a date DATE ( arg )
r_sample_report
shows some examples.
Tips for writing fixed width output
Set your expressions to a fixed width font like courier.
Split your fields into several expressions then add these together.
If your having problems try adding chevrons to the end of your strings
so that you can see how big it is.
e.g.
">" + column + "<"
Note:
Make sure that space() does not get a negative
value as this crashes Infomaker and dw2file.exe
with numbers you can use the string function to specify the
number of decimal places and any leading zeros
e.g.
String( size_x, "######0.00")
String( quote_no, "000000")
To justify numbers and strings two functions are available.
To acccess them you need to include dw2file_fun.pbd in you
library search path in Infomaker
(Enviroment - Design Menu - Options - Style Library Search Path)
To Justify Numbers use
justify_number(n,format,justification)
where
n is the number
format is the format mask e.g. "#####.00"
and
justification is either L,R,C for Left, Right Center
e.g.
justify_number(123.334,"######.00","C")
To Justify Numbers use
justify_string(string,width,justification)
where
string is text to be formatted
width is width to be used for justification
and
justification is either L,R,C for Left, Right Center
e.g.
justify_string("asd", 20 ,"L")
To break a string into lines of a maximum length
use
break_string(string, length)
where
string is text to be broken
length is maximum length of the line
e.g.
break_string(teststr, 30)
Download the program
dw2file.exe requires the PB deployment library
|