Chapter 11
(continued)
The askSam Report Writer
IF Statements
There are two ways to use conditional logic in askSam reports:
· IF Statements
· Conditional Field Setting
The IF Statement lets you divide your report layout into separate windows and create different scenarios based on a condition. For example: you could set up the IF statement to output a “Home” address in one format and a “Work” address in another format.
The Conditional Field setting affects only a single field. For example, you could use the Conditional Field setting to output “Mr.” before a name if the sex field contains “M” and “Ms.” before a name if the sex field contains “F”.
The IF Statement lets you divide your report layout into separate windows. Each window can contain a separate layout based on certain conditions.
To Use the IF Statement:
1. Create a new report (or go to an existing report).
2. Choose REPORT -> IF STATEMENT.
The If Statement Dialog Box will appear.
3. Choose ADD.
The Search Dialog will appear.
4. Define the condition for your IF Statement.
For example:
BOOK in the TYPE field
5. Choose OK.
You return to the If Statement Dialog. The condition you setup is listed.
6. Repeat steps 3 through 5 to complete the IF Statement.

7. Choose OK.
The report layout is split into multiple windows based upon the IF Statement you defined.
8. Place fields and text in each of the different IF windows.

When the report is run, the IF Statement is interpreted and the data will be output according to the format in the corresponding window.

NOTES:
1. The IF Statement cannot be used in reports that use grouping.
2. The BIBLIOGRAPHY.ASK file contains examples of reports using IF Statements.
3. The IF Statement always requires an “ELSE” as the last element.
The Conditional Field setting defines a set of conditions and how the field output should be affected by these conditions. For example, if the field is empty, output “N/A”. The Conditional Field setting is set in the Insert Field Dialog, and it only affects a single field.
To Use the Conditional Field Setting:
1. Click on the button after the field you want to make conditional.
The Insert Field Dialog Box will appear.
2. Choose the “Conditional Field” setting.
The If Statement Dialog Box will appear.
3. Choose ADD.
The Search Dialog will appear.
4. Define the condition for the field.
For example:
IF the field is empty
5. Choose OK.
You return to the If Statement Dialog. The condition you setup is listed.
The If Statement Dialog lets you define:
- Text to be output before the field.
- Text to be output after the field.
- Whether or not the field is output.
6. Repeat steps 3 through 5 to complete the IF Statement.

7. Choose OK.
You return to the Insert Field Dialog Box.
8. Choose OK.
The field will be updated with the conditional logic you defined. A question mark will appear before the field name in the Report Editor.

When the report is run, the conditional statement is interpreted and the data will be output accordingly.
NOTES:
1. The BIBLIOGRAPHY.ASK file contains examples of reports using the Conditional Field setting.
2. The Conditional Field setting always requires an “ELSE” as the last element.
Formatting Reports
You can define fonts, font sizes, colors, and styles for the information you output in a report. You can format specific fields, a grouped field, headers, footers, totals, or any text you include in a report.
To Define a Format in a Report:
1. In the Report Editor select the field or text you want formatted.
2. Choose the format you want set, either from the FORMAT menu or from the Format Bar. The Font, Font Size, and Color of the field or text in the Report Editor determine how that field or text will be formatted when you run the report.
For example, the report:

would output:

NOTES:
1. To format totals and subtotals, define the “Character Style” setting in the Total Dialog Box.
2. To format a Count Documents command in a report, define the font, color, and size of the Count button in the report layout.
3. In the Report Editor you can define formats in Headers, Footers, and Group Footers.
The default margins for reports are the same as margins in normal Documents. Use the Indent Markers in the Ruler to modify the margins in a report. Drag the Markers to the appropriate place to set your margins.
Editing Report Layouts
Once you have created a report, you can edit it at any time.
1. Choose TOOLS -> REPORTS and select the name of the report you want to edit.
2. Choose the EDIT button.
You will enter the Report Editor. You can now add, delete, format, or reposition fields. You can also modify the selection by choosing REPORT -> SELECT
DOCUMENTS. You can change the Sort order by choosing REPORT ->
SORTING AND GROUPING.
To Add a Field:
Drag a field name from the Field List into the report. The procedure is identical to creating a report layout. Alternatively, you can place the cursor where you want to insert the field and type the field name.
To Delete a Field:
Use the DEL or BACKSPACE keys to remove the field name from the report. Alternatively, you can select the field name you want to delete and press the DEL key.
To Format a Field:
Select a field name in the report. Then choose the desired formatting options from either the FORMAT menu or the Format Bar.
To Reposition a Field:
You can drag and drop fields and place them in new positions, or you can use the SPACE, ENTER, DEL, and BACKSPACE keys to move a field to the desired position.
When you are in the Report Editor, the standard edit and formatting functions from the askSam Word Processor are available.
|