The following script inserts the current page number in the footer of a document in a rich text control, then returns the focus to the body of the document:
rte_1.ShowHeadFoot(true,false)
rte_1.SetAlignment ( Center! )
rte_1.InputFieldInsert("PAGENO")
rte_1.ShowHeadFoot(false,false)
The PAGENO reserved word allows you to add the page number in headers and footers. In earlier versions of PowerBuilder, you could call SelectedPage in the PrintHeader or PrintFooter event, but these events are now obsolete.