Title.OnEntry( TOC("Init") ) GroupHeader.OnEntry( TOC("From", _PAGENO, GroupCaption) ) GroupFooter.OnExit( TOC("To", _PAGENO) )The User Defined Function TOC() creates a cursor and updates the cursor with the caption and page numbers. This concept could be enhanced to support different levels of groups, etc.
TOC("GetToc")
Use a non-proportional font for the field. Alternatively, you could create a separate report that prints a table of contents and call this report. This would give much more flexibility over the layout.*) Program...........: TOC.PRG * Author............: Daniel Gramunt * Created...........: 07.02.2001 - 15:02:39 *) Description.......: Creates a table of contents for a report. * Calling Samples...: * Parameter List....: * Major change list.: *-------------------------------------------------------------------------------------------------- LPARAMETER tcAction, tnPageNo, tcGroupCaption ASSERT VARTYPE(tcAction) = "C" AND; INLIST(UPPER(tcAction), "INIT", "FROM", "TO", "GETTOC"); MESSAGE "Parameter < tcAction > : Parameter missing or invalid value"+; "(Expecting 'INIT', 'FROM', 'TO' or 'GETTOC')" LOCAL lcAction, lnSelect, lcRetVal, lcClipText lcAction = UPPER(tcAction) lnSelect = SELECT() lcRetVal = "" DO CASE CASE lcAction = "INIT" *-- Initialize TOC (create the TOC cursor) *-- Called from the report's title.onEntry( TOC("Init") ) CREATE CURSOR TOC (Group C(50), From N(3), To N(3)) CASE lcAction = "FROM" *-- New group. Add group and starting pageno to TOC *-- called from the report's groupHeader.onEntry( TOC("From", _PAGENO, GroupExpression) ) INSERT INTO TOC VALUES(tcGroupCaption, tnPageNo, 0) CASE lcAction = "TO" *-- EOF group. Update TOC with ending pageno *-- called from the report's groupFooter.onExit( TOC("To", _PAGENO) ) REPLACE toc.To WITH tnPageNo IN toc CASE lcAction = "GETTOC" *-- Get TOC into a memvar *-- called from the report's summary field ( TOC("GETTOC") ) lcClipText = _CLIPTEXT GO TOP IN TOC _vfp.DataToClip("TOC",,1) lcRetVal = _CLIPTEXT _CLIPTEXT = lcClipText ENDCASE SELECT (lnSelect) RETURN lcRetVal>Hi all