Please enable JavaScript to view this site.

R:BASE 11 Help

Navigation: Reference Index > Using PAGEMODE

Example: Employee Telephone List

Scroll Prev Top Next More

This example prints an employee telephone list in columnar format. The page header data is actually written at the end of the page so it includes data from the first row printed on the page, and data from the last row printed on the page.

 

*(PHONE1.RMD)

*(example 1 - a columnar report with a page header

 written at the end of the page)

CON hifi

CLS

SET MESSAGE OFF

SET PAGEMODE OFF

SET LINES 10

DECLARE c1 CURSOR FOR +

 SELECT (LastName + ',' & FirstName), Phone, Lastname +

 FROM salespeople ORDER BY lastname

OPEN c1

FETCH c1 INTO vName i1 ,vPhone i2, vLastname I3

SET VAR vCol INT = 1, vRow INT = 3, vRowLimit = 9

SET VAR vFirst TEXT = .vLastname, +

       vLast TEXT = .vLastname,+

       vPage INT = 1

SET PAGEMODE ON

OUTPUT phone.out

WHILE SQLCODE <> 100 THEN

  SET VAR vRow = (.vRow + 1)

  IF vRow >= .vRowLimit THEN

    IF vCol = 40 THEN

      WRITE .vFirst '-' .vLast AT 2 1

      WRITE 'Page' .vPage AT 2 68

      WRITE '----------------------------------' AT 3 1

      WRITE '----------------------------------' AT 3 40

      NEWPAGE

      SET VAR vFirst = .vLastname, vLast = .vLastname

      SET VAR vPage = (.vPage + 1), vCol = 1

    ELSE

      SET VAR vCol = 40

    ENDIF

    SET VAR vRow = 4

  ENDIF

  WRITE .vName=21 .vPhone AT .vRow .vCol

  SET VAR vLast = .vLastname

  FETCH c1 INTO vName i1, vPhone i2, vLastname I3

ENDWH

WRITE .vFirst '-' .vLast at 2 1

WRITE 'Page' .vPage at 2 68

WRITE '----------------------------------' at 3 1

WRITE '----------------------------------' at 3 40

OUTPUT SCREEN

CLOSE c1

DROP CURSOR c1

SET PAGEMODE OFF

SET LINES 20

TYPE phone.out