Using Older SQR Commands

This section discusses each of the older SQR commands.

You should no longer use this command because it may be discontinued in a future release. To use the newer SQR functionality, use BEGIN-PROGRAM.

Syntax

Use this syntax:

BEGIN-REPORT

Description

Begins a report.

After processing the commands in the SETUP section, SQR starts running the program at the BEGIN-REPORT section. The PROGRAM section typically contains a list of DO commands, though you can also use other commands. This section is the only required section in an SQR program.

Example

For example:

begin-report
   do startup
   do main
   do finish
end-report

You should no longer use this command because it may be discontinued in a future release. To use the newer SQR functionality, use the datenow function in the LET command.

Syntax

Use this syntax:

DATE-TIME  position [date_format[col_var]]

Description

Retrieves the current date and time from the local machine (or from the database for Oracle and some IBM DB2 platforms) and places it in the output file at the specified position or into a column variable.

If col_var is specified, then date_format must be supplied and the current date and time is retrieved each time this command is run. Otherwise, the date is retrieved only at the program start, and the same date and time is printed each time.

If date_format is not specified, the date is returned in the default format for that database. The following table provides the default date-time formats for SQR-supported databases:

Database

Default Date-Time Format

Oracle

DD-Mon-YYYY  HH:MI PM

IBM DB2

YYYY-MM-DD-HH:MI YYYY-MM-DD- HH:MI:SS.NNNNNN

Some databases have two default formats. The first format prints the date-time, as in the following example:

date-time (+1,1)

The second format retrieves the date-time into a column variable:

date-time () '' &date1

For databases with only one default format, that format is always used in either of these cases.

See the table showing miscellaneous functions under the LET command for information about the valid edit mask format codes.

Parameters

Field or Control

Definition

position

Specifies the position for printing the date.

date_format

Represents a string literal containing the date format mask.

col_var

Places the retrieved date-time into a column variable rather than in the output file.

Example

For example:

date-time (1,50)  MM/DD/YY
date-time (1,1) 'Day Mon DD, YYYY'
date-time ()  HH:MI  &time
date-time (+1,70) 'MON DD YYYY HH24:MI' &datetime
date-time (#i, #j) 'YYYY-MM-DD' &date1

See the $current-date reserved and datenow functions that are described in the table showing miscellaneous functions under the LET command.

See ALTER-LOCALE.

You should no longer use this command because it may be discontinued in a future release. To use the newer SQR functionality, use DECLARE-LAYOUT and DECLARE-PRINTER.

Syntax

Use this syntax:

DECLARE PRINTER
[TYPE=printer_type_lit]
[ORIENTATION=orientation_lit]
[LEFT-MARGIN=left_margin_num_lit]
[TOP-MARGIN=top_margin_num_lit]
[LINE-SIZE=line_size_num_lit]
[CHAR-SIZE=char_size_num_lit]
[LINES-INCH=lines_inch_int_lit]
[CHARS-INCH=chars_inch_num_lit]
[POINT-SIZE=point_size_num_lit]
[FONT-TYPE=font_type_txt_lit]
[SYMBOL-SET=symbol_set_id_lit]
[STARTUP-FILE=file_name_txt_lit]
[FONT=font_int_lit]
[BEFORE-BOLD=before_bold_string_txt_lit]
[AFTER-BOLD=after_bold_string_txt_lit]

Description

Specifies the printer type and sets printer characteristics.

Use the DECLARE PRINTER command either in the SETUP section or in the body of the report. Generally, you should use it in the SETUP section. However, if you do not know what type of printer you will be using until the report is run, or if you need to change some of the arguments depending on user selection, you can put several DECLARE PRINTER commands in the body of the report and run the one that you need.

The following arguments take effect only once, upon execution of the first PRINT command, and thereafter have no effect even if changed:

      LINE-SIZE
      CHAR-SIZE
      LINES-INCH
      CHARS-INCH
      ORIENTATION

SQR maps its line and column positions on the page by using a grid that is determined by the LINE-SIZE and CHAR-SIZE (or LINES-INCH and CHARS-INCH) arguments. Each printed piece of text is placed on the page by means of this grid. Because the characters in proportional fonts vary in width, a word or string may be wider than the horizontal space that you have allotted, especially in words containing uppercase letters. To account for this behavior, you can either move the column position in the PRINT statement or indicate a larger CHAR-SIZE value in the DECLARE PRINTER command.

Arguments

The following table describes the arguments for the DECLARE PRINTER command:

Argument

Choice or Measure

Default Value

Description

TYPE

LINE­PRINTER, POSTSCRIPT, HPLASERJET

LINE­PRINTER

SQR creates output that is specific to each printer.

Line printer files generally contain ASCII characters and can be viewed by a text editor.

PostScript files contain ASCII characters, but you need to know PostScript to understand what will appear on the printer.

HP LaserJet files are binary files and cannot be edited or viewed.

ORIENTATION

PORTRAIT, LANDSCAPE

PORTRAIT

Portrait pages are printed vertically.

Landscape pages are printed horizontally.

Printing in landscape mode on HP LaserJet printers requires landscape fonts.

LEFT-MARGIN

inches

0.5

This argument does not apply to line printers.

This is the amount of blank space to leave at the left side of the page.

TOP-MARGIN

inches

0.5

This argument does not apply to line printers.

This is the amount of blank space to leave at the top of the page.

LINE-SIZE

points

12

This argument does not apply to line printers.

This is the size of each SQR line on the page. There are 72 points per inch. If LINE-SIZE is not specified, it follows the value for POINT-SIZE, if specified. The default value of 12 points yields 6 lines per inch.

CHAR-SIZE

points

7.2

This argument does not apply to line printers.

This is the size of each SQR horizontal character column on the page (for example, the distance between the locations [1,12] and [1,13]). If CHAR-SIZE is not specified and the point size is less than 8.6, CHAR-SIZE is set to 4.32, which yields 16.6 characters per inch. The default value of 7.2 yields 10 characters per inch.

LINES-INCH

lines

6

This argument does not apply to line printers.

This is an alternate way of indicating the, in lines per inch rather than in points (as in LINE-SIZE).

CHARS-INCH

characters

10

This argument does not apply to line printers.

This is an alternate way of indicating the width of each SQR character column, in characters per inch rather than in points (as in CHAR-SIZE).

POINT-SIZE

points

12

This argument does not apply to line printers.

This is the beginning size of the selected font.

FONT-TYPE

PROPORTIONAL, FIXED

Depends on the font

This argument applies only to HP LaserJet printers and must be specified only for font types that are not listed as being available for HP LaserJet printers in SQR in the previous DECLARE-PRINTER section.

SYMBOL-SET

HP defined sets

0U

This argument applies only to HP LaserJet printers. The default value, 0U, is for the ASCII symbol set. Additional symbol sets exist.

See HP LaserJet Technical Reference Manual.

STARTUP-FILE

filename

POSTSCRI.STR

This argument applies only to PostScript printers. Use it to specify an alternate startup file. Unless otherwise specified, the default startup file is located in the directory that is specified by the environment variable SQRDIR.

FONT

font_number

3

This is the font number of the typeface to use. For HP LaserJet printers, this is the typeface value as defined by Hewlett-Packard.

See HP LaserJet Technical Reference Manual.

For PostScript printers, SQR supplies a list of fonts and arbitrary font number assignments in the postscri.str file. The font numbers are the same as those for HP LaserJet printers, wherever possible, so that you can use the same font number for reports to be printed on both types of printers. You can modify the font list in postscri.str to add or delete fonts. Read the postscri.str file for instructions. See the fonts that are listed as being available for HP LaserJet printers in SQR in the previous DECLARE-PRINTER section. See also the table that lists the fonts that are available in the SQR postscri.str file, also in the DECLARE-PRINTER section.

BEFORE-BOLD

any string

None

The BEFORE-BOLD and AFTER- BOLD arguments are for line printers only. They specify the character string to turn bold on and off. If the string contains blank characters, enclose it in single quotation marks. To specify nonprintable characters, such as ESC, enclose the decimal value within angle brackets as follows: BEFORE-BOLD=<27>[r ! Turn on bold AFTER-BOLD=<27>[u ! Turn it off

These arguments work with the BOLD argument of the PRINT command.

AFTER-BOLD

any string

None

See BEFORE-BOLD.

The font that you choose—its orientation, typeface, and point size—must be an internal font (available in a font cartridge) or downloaded to the printer.

For fonts that are not listed as being available for HP LaserJet printers in SQR in the “DECLARE-PRINTER” section in the “SQR Command Reference” topic, you must indicate the font style by using the FONT-TYPE argument; otherwise, the printer cannot select the correct typeface.

You should no longer use this command because it may be discontinued in a future release. To use the newer SQR functionality, use DECLARE-PROCEDURE.

Syntax

Use this syntax:

DECLARE PROCEDURE
[BEFORE-REPORT=procedure_name]
[AFTER-REPORT=procedure_name]
[BEFORE-PAGE=procedure_name]
[AFTER-PAGE=procedure_name]

Description

Defines specific event procedures.

Use the DECLARE PROCEDURE command either in the SETUP section or in the body of the report. You can use the command as often as you like.

If you issue multiple DECLARE PROCEDURE commands, the last one takes precedence. In this way, you can turn procedures on and off while a report is running. The referenced procedures do not take any arguments; however, they may be local. In addition, they can print only into the body of the report; that is, they cannot print into the header and footer areas.

Parameters

Field or Control

Definition

BEFORE-REPORT

Specifies a procedure to run at the time of the first PRINT command. For example, you use this to create a report heading.

Field or Control

Definition

AFTER-REPORT

Specifies a procedure to run just before the report file is closed at the end of the report. Use this to print totals or other closing summary information. If no report was generated, the procedure does not run.

BEFORE-PAGE

Specifies a procedure to run at the beginning of every page, just before the first PRINT command for the page. For example, you use this to set up page totals.

Field or Control

Definition

AFTER-PAGE

Specifies a procedure to run just before each page is written to the file. For example, you use this to display page totals.

Example

For example:

declare procedure
   before-page=page_setup
   after-page=page_totals

You should no longer use this command because it may be discontinued in a future release. To use the newer SQR functionality, use ALTER-LOCALE.

Syntax

Use this syntax:

DOLLAR-SYMBOL  new_symbol

Description

Redefines the currency symbol within numeric edit masks .

The dollar sign ($) is the default currency symbol for coding edit masks in the program that prints on report listings. DOLLAR-SYMBOL provides a way to change that symbol for both the edit mask and for printing.

To change the symbol that prints on the report, use MONEY-SYMBOL in the PROCEDURE section. Use DOLLAR-SYMBOL and MONEY-SYMBOL together to configure SQR programs and the reports that they produce.

Use this command only in the SETUP section.

Note: The MONEY-SYMBOL command has the same effect as these options of the ALTER-LOCALE command: MONEY-SIGN and MONEY-SIGN-LOCATION=LEFT.

The following table lists the characters that DOLLAR-SYMBOL cannot take:

Type

Character

Numbers

0 8 9

Alphabetical

b e n r v B E N R V

Symbols

. , - + ! * _ ` < > ( )

Parameters

Field or Control

Definition

new_symbol

Specifies a new, single character to be used in edit masks instead of the dollar sign ($).

Example

For example:

begin-setup
 dollar-symbol £      ! Define £ as the currency symbol
end-setup
begin-procedure
...
print #amount () edit £££,999.99
...
end-procedure

In the previous example, if you used the dollar sign in the edit mask after defining the dollar symbol as £, the following error message appears:

Bad numeric 'edit' format: $$$,999.99

See the ALTER-LOCALE command for a description of other locale-specific parameters.

You should no longer use this command because it may be discontinued in a future release. To use the newer SQR functionality, use ALTER-PRINTER and DECLARE-PRINTER to set the FONT, FONT-TYPE, POINT-SIZE, and PITCH.

Syntax

Use this syntax:

GRAPHIC  () 
FONT  { font_number_int_lit|_var } 
[point_size_int_lit|_var[{1|0}
[pitch_int_lit|_var]]]	

Description

Changes a font.

Parameters

Field or Control

Definition

font_number

For HP LaserJet printers, the specified font must be installed in the printer. For PostScript printers, the font must be defined in the postscri.str file.

Field or Control

Definition

point_size

If point_size is omitted, the size from the most recent DECLARE-PRINTER or GRAPHIC FONT command is used.

Field or Control

Definition

{1|0}

This argument is for HP LaserJet printers only. It is needed only if you are using a font that SQR does recognize. (See the fonts that are listed as being available for HP LaserJet printers in SQR in the DECLARE-PRINTER section of the topic “SQR Command Reference.”) A 1 indicates a proportional font, and a 0 indicates a fixed-pitch font. The default is proportional.

Field or Control

Definition

pitch

If the specified font is fixed pitch, also indicate the pitch in characters per inch.

Example

For example:

graphic () font  23  8.5      ! Century Schoolbook, 8.5 points
graphic () font  6  12  0  10 ! Letter Gothic, 12 points, 
                              ! fixed, 10 characters per inch
graphic () font :#font_number :#point_size

See ALTER-PRINTER and DECLARE-PRINTER for information about setting and changing the FONT, FONT-TYPE, POINT-SIZE, and PITCH.

You should no longer use this command because it may be discontinued in a future release. To use the newer SQR functionality, use ALTER-LOCALE.

Syntax

Use this syntax:

MONEY-SYMBOL new_symbol

Description

Redefines the currency symbol to be printed.

To change the symbol that prints on the report, use the MONEY-SYMBOL in the PROCEDURE section. When the MONEY-SYMBOL is set, that value is used until the next MONEY-SYMBOL command runs.

Use DOLLAR-SYMBOL and MONEY-SYMBOL together to configure SQR programs and the reports that they produce.

To indicate a nonedit character, surround its decimal value with angle brackets (<>). See the table under the DOLLAR-SYMBOL command for characters that cannot be used with MONEY-SYMBOL.

Note: The MONEY-SYMBOL command has the same effect as the MONEY-SIGN and MONEY-SIGN-LOCATION=LEFT options of the ALTER- LOCALE command.

Parameters

Field or Control

Definition

new_symbol

Specifies a new, single character to replace the dollar sign ($) or DOLLAR-SYMBOL character on the printed report.

Example

For example:

begin-setup
 dollar-symbol £! Define £ as the 

   ! currency symbol
end-setup
begin-procedure! If #Amount=1234.56
...
money-symbol £
print #Amount () Edit £££,999.99   ! Prints as: £1,234.56
...
money-symbol $
print #Amount () Edit £££,999.99   ! Prints as: $1,234.56
...
money-symbol  
print #Amount () Edit £££,999.99   ! Prints as:  1,234.56
...
end-procedure

See the DOLLAR-SYMBOL and ALTER-LOCALE commands.

You should no longer use this command because it may be discontinued in a future release. To use the newer SQR functionality, use the FORMFEED parameter of the DECLARE-LAYOUT command.

Syntax

Use this syntax:

NO-FORMFEED

Description

Prevents form-feed characters from being written to the output file.

NO-FORMFEED is useful for certain types of reports; for example, flat file output. It is used only in the SETUP section.

Do not write form-feed control characters directly into the output file between pages.

Example

For example:

begin-setup
  no-formfeed
end-setup

You should no longer use this command because it may be discontinued in a future release. To use the newer SQR functionality, use the MAX-LINES and MAX-COLUMNS parameters of the DECLARE-LAYOUT command.

Syntax

Use this syntax:

PAGE-SIZE  page_depth_num_lit  page_width_num_lit

Description

Sets the page size.

If you are printing multiple reports, you must use the PAPER-SIZE parameter of the DECLARE-LAYOUT command.

This command is used in the SETUP section only.

Specify the page depth in lines and the page width in columns. An average report that is printed on 8 1/2 by 11 inch paper might have a page size of 60 lines by 80 columns. A 3-inch by 5-inch sales lead card might have a size of 18 by 50.

If the page size is not specified, the default of 62 lines by 132 columns is used.

For line printers, SQR stores one complete page in a buffer before writing the page to the output file when you issue a NEW-PAGE command or when a page overflow occurs.

You can define a page to be 1 line deep and 4,000 characters wide, which you can use for writing large flat files, perhaps for copying to magnetic tape. Each time a NEW-PAGE occurs, one record is written. Use the NO-FORMFEED command in the SETUP section to suppress form-feed characters between pages.

Use a page width that is at least one character larger than the rightmost position that will be written. This prevents unwanted wrapping when printing. When the last column position on a line is printed, the current position becomes the first position of the next line. This can cause confusion when using relative line positioning with the NEXT-LISTING command. Having a wider page than necessary does not waste any file space because SQR trims trailing blanks on each line before writing the report file.

Determine the size of the internal page buffer that stores a complete page in memory by multiplying the page depth by the width in the PAGE-SIZE command. For personal computers, the page buffer is limited to 64K bytes. On other computers, the page buffer is limited only by the amount of memory that is available.

Example

For example:

begin-setup
  page-size  57  132! 57 lines long by 132 columns wide
end-setup

You should no longer use this command because it may be discontinued in a future release. To use the newer SQR functionality, use PRINT … CODE-PRINTER.

If you use CODE, the sequence is assumed to be for the printer type that is specified in the DECLARE-REPORT or for the default printer, if none is specified.

Syntax

Use this syntax:

PRINT . . . CODE

Parameters

Field or Control

Definition

CODE

CODE is a qualifier that may be discontinued in a future release. Use CODE-PRINTER instead.

You should no longer use this command because it may be discontinued in a future release. To use the newer SQR functionality, use the RESET-STRING parameter of the DECLARE-PRINTER command.

Syntax

Use this syntax:

PRINTER-DEINIT  initialization_string

Description

Sends control or other characters to the printer at the end of a report.

Specify nondisplay characters by placing their decimal values inside angle brackets. For example, <27> is the ESC or escape character.

The PRINTER-DEINIT command is used only in the SETUP section and is designed for use with line printers. It has limited functionality with HP LaserJet and PostScript printers.

Example

For example:

begin-setup
  printer-deinit<27>[7J ! Reset the printer
end-setup

You should no longer use this command because it may be discontinued in a future release. To use the newer SQR functionality, use the INIT-STRING parameter of the DECLARE-PRINTER command.

Syntax

Use this syntax:

PRINTER-INIT initialization_string

Description

Sends control or other characters to the printer at the beginning of a report.

Specify nondisplay characters by placing their decimal values inside angle brackets. For example, <27> is the ESC or escape character.

The PRINTER-INIT command is used only in the SETUP section and is designed for use with line printers. It has limited functionality with HP LaserJet and PostScript printers.

Example

For example:

begin-setup
  printer-init<27>[7J ! Set the printer
end-setup