Dec 132017
 
How to embed variables in Paradox reports.
File RPTVAR.ZIP from The Programmer’s Corner in
Category Paradox DBMS
How to embed variables in Paradox reports.
File Name File Size Zip Size Zip Type
RPTVAR.TXT 4821 1827 deflated

Download File RPTVAR.ZIP Here

Contents of the RPTVAR.TXT file


INSERTING VARIABLES IN PARADOX REPORTS (1.1 AND 2.0)


Introduction

At times, it may be desirable to incorporate a variable in a Paradox report.
You may wish to print a date other than the current date at the top of the
report, or perhaps assign the results of a calculation performed elsewhere to a
variable for inclusion in a report.

The technique described here works only if the variable will be used as a
constant in the report. In other words, the variable itself may not change its
value during the course of report generation.

Paradox does not allow IF-THEN or AND-OR logic within the report itself. You
cannot design a report that will print or perform a calculation on a record based
upon a previously specified condition. The best way to achieve the effect of
AND-OR logic is to report from an Answer table generated by an earlier
preselection process. You can produce a suitable Answer table through one or
more queries. PAL offers specific IF-THEN and SWITCH-CASE program control
structures which allow the system designer to specify a series of actions based
upon two or more sets of conditions.


Outline of Technique

A value must be assigned to the variable before referring to it in a report
form. This is done in a PAL script. An example of a short PAL script which
prompts the user for a value to be assigned to a variable may be seen later in
this article.

1. Starting from the Main Menu in Paradox, create a script using
Scripts/BeginRecord or Instant Script Record (Alt F3).

o Choose Report/Change/... etc. to select the table and the report form in
which you want to place the variable.

o Use the arrow keys to position the cursor at the place in the report where
the variable will be inserted. You may wish to make use of various
combinations of Line Delete (Ctrl Y), Insert (Ins), Backspace, and Enter
keys to alter or delete existing values.

o Press Alt-F10 and choose EndRecord to turn off Script Record.

So far, you have generated an Instant script that opens a report
specification for modification and positions the cursor at the point where
further developments will take place.

2. Select Scripts\Editor\Write from the Main Menu in Paradox. You are opening
a new script into which you will read the Instant Script created in Step 1.

o Press the Insert key and then press F10 to bring up the PAL Script Editor
Menu.

o Choose Read from the Script Editor menu and enter the name of the script
created in step 2. (This name is Instant if you used the Instant Script
Record feature.) Paradox will combine the two scripts.


3. Next, type in the following lines below the script that you inserted with
the Read option:

typein variable ;(where variable is the variable name)
Do_It!


4. You can now add the commands to generate the report output at the end of
this script. The report will print with the current value of the variable
included.


Some Example Scripts

o Script segment to assign value to variable (in this case, a date) to be used
in report (Step 1)

Clear
@ 10,10
?? "Enter date to be used in report header"
Accept "D" to date ;date is the name of the variable


o Example of a script recorded using Instant Script Record (Step 2)

{Report} {Change} {c:\\paradox\\products} {1} Enter Down Down Down
;note the double backslashes in the line above -
;a backslash or a quote in curly braces must be
;preceded with a backslash.

typein date ;(Step 4)
Do_It!


o Example of PAL commands to generate report output (Step 5)

Report "Products" "1"

In this case, "Products" represents the table which contains the data you
wish to print, and "1" represents the report form that you have previously
designed for that table.


The Completed Script

Clear
@ 10,10
?? "Enter date to be used in report header"
Accept "D" to date ;date is the name of the variable

{Report} {Change} {c:\\paradox\\products} {1} Enter Down Down Down
;note the double backslashes in the line above -
;a backslash or a quote in curly braces must be
;preceded with a backslash.

typein date ;(Step 4)
Do_It!

Report "Products" "1" ;output the report




Conclusion

This technique can be applied in other ways to enhance your custom report
designs. Anything that can be assigned to a variable can be placed in a report.


 December 13, 2017  Add comments

Leave a Reply