     /*******************************************************/
     /* This report script will create a report of all      */
     /* the messages from the file defined in the VIRTUAL   */
     /* section.  The messages will be sorted according to  */
     /* SUBJECT and NUMBER.                                 */
     /*******************************************************/

START

VIRTUAL

  msg_file      STRING  32      "D:\WR\MSGS.DAT"        /* Message base */


  str_number    STRING  12      LNG_STR(number)
  left_date     DATE     4      date

  read_date     DATE     4      (STRIP(to) <> "ALL" AND date_read = 0)
                                 ? 1 : date_read

  referto       STRING  12      (refer = 0) ? "None" : LNG_STR(refer)


  vf1           INT2     2      (type <> 82 AND type <> 83) ? 1 : 0
  vf2           INT2     2      (type = 82) ? 2 : 0
  vf3           INT2     2      vf1 + vf2              /* This Section    */
                                                       /* allows you to   */
  security      STRING 10      : vf3                   /* manipulate the  */
                                 0 "Password"          /* the security    */
                                 1 "None"              /* field.          */
                                 2 "Private"


SEARCH 

  FILE msg_file USING_KEY number_index1   /* # after index = forum # */



     /*******************************************************/
     /* The SELECTION section is where you tell the report  */
     /* generator how to select individual records. In this */
     /* case we do not want to print any messages that are  */
     /* private (type = 'R' [82])                           */
     /*******************************************************/


SELECT

   type <> 82                      /* no private mail */


SORT USING_KEY

  NO_MOD       subject            /* sort by subject       */
  INTEGER      number             /*  and number           */


CONTROL                           /* print the subject at  */ 
                                  /* beginning of each     */
  1     subject                   /* group                 */


ACCUMULATOR                       /* keep a running total  */
                                  /* of the threads in     */
  thread_total  FRQ     subject   /* each group            */


DISPLAY

  DEVICE        OUTFILE            /* send report to a file */
  PAGE_LENGTH   0                  /* no page formatting    */



IMAGE

REPORT_HDR
+
+                Writer's Forum Message Thread Report
+                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+Number     Written by           Written to          Date

CONTROL_HDR(1)
+Subject Heading : @xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
                    subject
+
BODY
+@xxxxxx@xxxxxxxxxxxxxxxxxxxx@xxxxxxxxxxxxxxxxxxxx@xxxxxxxx
 number  from                  to                  left_date

CONTROL_FTR(1)
+Total: @999
         thread_total
+~~~~~



     /*******************************************************/
     /* EXIT must be the last line in each script           */
     /*******************************************************/


EXIT

