Positioning Text

In SQR for PeopleSoft, you position text according to a grid. That grid is set by default to 10 characters per inch and 6 lines per inch, but you can give it another definition by altering the CHAR-WIDTH and LINE-HEIGHT parameters of the DECLARE-LAYOUT command.

Note, however, that character grid and character size function independently of each another. Fonts print in the size that is set by DECLARE-PRINTER or ALTER-PRINTER, not the size that is defined by the grid. A character grid is best used for positioning the first character in a string. It can express the width of a string only in terms of the number of characters that it contains, not in an actual linear measurement, such as inches or picas.

When you use a proportionally spaced font, the number of letters that you print may no longer match the number of character cells that the text actually fills. For example, in the following sample code the word Proportionally fills only 9 cells, although it contains 14 letters.

When you print consecutive text strings, the actual position at the end of a string may differ from the position that SQR assumes according to the grid. For this reason, concatenate consecutive pieces of text and print them as one.

For example, do not write code like this:

alter-printer font=5    ! select a proportional font
print &first_name ()    ! print first name
print ' ' ()            ! print a space
print &last_name ()     ! print the last name
alter-printer font=3    ! restore the font

Instead, write code like this:

alter-printer font=5    ! select a proportional font
! concatenate the name
let $full_name = &first_name || ' ' || &last_name
print $full_name ()     ! print the name
alter-printer font=3    ! restore the font

The WRAP and CENTER options of the PRINT command also require special consideration when used with proportional fonts. They both calculate the text length based on the character count in the grid, which is not the same as its dimensional width.

Look at the sample program. It contains a list of reminders from the reminders table. It is printed in a mix of fonts: Times Roman in two different sizes plus Helvetica bold.

Program ex14a.sqr
begin-setup
 declare-layout default
   paper-size=(10,11)
 end-declare
end-setup
begin-program
 do main
end-program
begin-procedure main
! Set Times Roman as the font for the report
alter-printer font=5 point-size=12
begin-select
remind_date    (,1,20) edit 'DD-MON-YY'
reminder       (,+1) wrap 60 5
  position (+2)
from reminders
end-select
end-procedure ! main
begin-heading 7
 print $current-date    (1,1) Edit 'DD-MON-YYYY'
 page-number (1,60) 'Page ' 
 ! Use large font for the title
 alter-printer font=5 point-size=24
 print 'Reminder List'      (3,25)
 ! Use Helvetica for the column headings
 alter-printer font=4 point-size=12
 print 'Date' (6,1) bold
 print 'Reminder' (6,22) bold
 graphic (6,1,66) horz-line
 ! Restore the font
 alter-printer font=5 point-size=12
end-heading

The report uses the default layout grid of 10 characters per inch and 6 lines per inch both for positioning the text and for setting the length of the solid line.

The font is set at the beginning of the main procedure to font 5, which is Times Roman. The point size is set to 12. In the HEADING section, its size is set to 24 points to print the title.

The column headings are set to 12-point Helvetica with the ALTER-PRINTER FONT=4 POINT-SIZE=12 command. The BOLD option of the PRINT command specifies that they be printed in bold.

A solid line is under the column headings. Note that it is positioned at line 6, the same as the column headings. SQR draws the solid line as an underline. At the end of the HEADING section, the font is restored to Times Roman.

In an SQR program, the report heading is performed after the body. A font change in the heading does not affect the font that is used in the body of the current page, although it changes the font that is used in the body of subsequent pages. Keep track of your font changes and return fonts to their original settings in the same section in which you change them.

Positioning the title requires careful coding. The CENTER option of the PRINT command does not work because it does not account for the actual size of the text. Instead, position the title by estimating its length. In this case, the title should start 2 1/2 inches from the left margin. The character coordinates are (3,25), which is line 3, character position 25. Remember that the character grid used for positioning assumes 10 characters per inch; therefore, 25 characters is 2 1/2 inches.