Q: How can I get page 'x of y' on my output (versions prior to v3.0.x)?

A: See following sample report. Note that SQR Version 3.0 directly support printing the page number of the last page.

---------------------------- Example code begins here -------------------------
begin-report
 do main
end-report

begin-setup
 page-size 10 80
end-setup

begin-footing 2
 page-number (2,32) 'Page '
 print ' of ' ()
 add 1 to #pcnt                         ! add 1 to page count variable
end-footing

begin-procedure main
begin-select
deptno (+1,1)
empno (,10)
ename (,20)
from emp
order by deptno
end-select

 new-report 'junk.lis'                  	! close the lis file
 open 'pagetest.lis' as 1 for-reading record=80	! open the lis file
 open 'pagetest.out' as 2 for-writing record=80 ! open another output file
 move #pcnt to $pcnt 99

 while 1                                ! loop reading records in the lis file
  read 1 into $rec:80
  if #end-file
   break
  end-if
  let #pos1 = instr($rec,'Page',1)      ! test whether the string
  let #pos2 = instr($rec,'of',1)        ! has 'Page' and 'of'
  if #pos1 != 0 and #pos2 != 0          ! if so, add the total page to string
   let $newrec = $rec || $pcnt
   write 2 from $newrec:80              ! write new line to out file
  else
   write 2 from $rec:80                 ! otherwise write the line to out file
  end-if
 end-while
 close 1
 close 2
end-procedure