5

The LA Fox Developer Newsletter
November 1997
FoxPro Q&A (Con’t from page 4)
Q In a FoxPro Report, can / force a routine in the middle of the detail band, based on some condition, to skip to a new page? To force a routine in the middle of the report based on a condition:

1.
Create a report variable (say var) and set it so that its “Value
to Store” is chkpage() and its “Initial Value” is 0. Check the Sum function option.

2.
Create a function (UDF) called “chkpage” that returns 1 if you
Nant a page break after the current record or 0 if you don’t want
a break. In other words, you effectively increment the variable
called "var" if a page break is required.

3.
Create a data grouping based on the expression “var” and set
it to print on a “New Page”. This data grouping would be for your detail band (or other group bands, if that’s appropriate in your ease).

Note! You can insert a page break only after the current record and not before it.


Q How can I change the picture clause of a @GET dynamically?

A You are not permitted to change the picture clause when the read is active. However, you can try the following workaround:

1.
Declare two Get fields with the same height and width.
2.
Assign different picture clauses to each one.
3.
Initially disable both the fields and place them exactly one
over the other.

4.
Try selecting the appropriate fields using the SHOW GET
<var> ENABLE command and disabling the other field using the SHOW GET <var> DISABLE command.


Q How can I send a graphics-based report created in FoxPro for Windows to a text file?

A To print a report to a text file in FoxPro for Windows, use the Windows printer setup application in the Control Panel. To install the Windows Generic/Text Only printer driver, follow the steps below:

1.
Run the Windows Control Panel.
2.
Double-click the Printers icon.
3.
Click the Add button.
4.
Under List of Printers, select the Generic/Text Only printer
driver and click the Install button. This places the Generic/Text Only printer driver under the list of Installed Printers.

5.
Under Installed Printers, select the Generic/Text Only printer
driver, click the Connect button, select FILE in the Ports list box, and then click the OK button.

6.
Select the Generic/Text Only printer driver, click the Set As
Default Printer button, and then click the Close button.

Before printing your report, turn off any bold or italic fonts. Issue the REPORT FORM <Reportflle> TO <Textfile> command, where <reportfile> is the name of the .FRX file and <Textfile> is the name of your output text file.


Q How can I create a set of Navigational Buttons to navigate through a table?

A You can create a set of Navigational Buttons to navigate through records in a table. They can be used to go to the next, previous, top or bottom records in the selected table.

How to go about doing it:

1.
Create a set of four pushbuttons labelled Next, Previous, Top
and Bottom. Set the variable to m.navigate.
2.
Type the following code in the Valid clause of the screen:
DO CASE
CASE m.navigate = 1
SKIP I
IFEOF()
WAIT WINDOW “END OF FILE HAS BEEN REACHED’ GO BOTTOM
ENDIF
CASE m.navigate = 2
SKIP -1
IF BOFØ
WAIT WiNDOW “BEGINNING OF FILE HAS BEEN;
REACHED”
GO TOP
ENDIF
CASE m.navigate = 3
GO TOP
CASE m.navigate = 4
GO BOTTOM
ENDCASE
SHOW GETS

3.
Save the screen and run it. You can now use the buttons to
navigate through your table.


(Con’t, page 6)
Page 5

5