NAME "ROSTER"

CLEAR
PUT "Please Select The Individuals To Be Included In This Roster:"
PRINT TO SCREEN 1 2 3
ASSIGN MENU(4,4,"PENDING + ACTIVE",4,5,"CANDIDATE",
            4,6,"PENDING",4,7,"ACTIVE",4,8,"INACTIVE",4,9,"VETERAN",
            4,10,"MAILONLY",4,11,"HISTORICAL") TO %0
PUT "How Do You Wish The Roster To Be Sorted?"
PRINT TO SCREEN 1 14 3
ASSIGN MENU(4,16,"ALPHABETICALLY",4,17,"BY DENS") TO %1

ASSIGN 0 TO %2
WHILE (STATUS GE 0)
   IF (STATUS GT 0)
      IF (((%0 EQ 1) AND ((STATUS EQ 2) OR (STATUS EQ 3))) OR (STATUS EQ (%0 - 1)))
         ASSIGN (%2 + 1) TO %2
         ASSIGN "0" TO $0
         IF (ADULT)
            ASSIGN "1" TO $0
         ENDIF
         PUT $0
         IF (%1 EQ 2)
            PUT DEN USING (W2)
         ENDIF
         ASSIGN UPCASE(LAST_NAME) TO $0
         ASSIGN INDEX(",",$0) TO %3
         IF (%3 GT 0)
            ASSIGN SUBSTR($0,1,%3 - 1) TO $0
            WHILE (LENGTH($0) LT 18)
               ASSIGN ($0 CONCAT " ") TO $0
            ENDWHILE
         ENDIF
         PUT $0
         PUT UPCASE(FIRST_NAME)
         PRINT TO KEYS
      ENDIF
   ENDIF
   NEXT ID
ENDWHILE

IF (%2 EQ 0)
   CLEAR
   PUT "Sorry - There Are No Individuals In This Data File Of The Specified Status."
   PRINT TO SCREEN 1 10 4
   PUT "(Press Any Key To Continue)"
   PRINT TO SCREEN 26 25 3
   PAUSE
   ABORT
ENDIF

SORT

ASSIGN 66 TO %6   # Total number of lines on the page
ASSIGN 1 TO %7    # Current page number
ASSIGN %6 + 1 TO %8   # Current line number
ASSIGN KEYBUF(1,1) TO $49
WHILE (%2 GT 0)
   IF ((%8 GT (%6 - 9)) OR (KEYBUF(1,1) NE $49))
      WHILE (%8 LT 67)
         PUT "\010"
         ASSIGN (%8 + 1) TO %8
      ENDWHILE
      PUT "\013\010"
      PRINT TO REPORT
      PUT UNIT_NAME
      PUT " "
      PUT LOCAL
      IF ((%0 EQ 1) OR (%0 EQ 4))
         IF (STATUS EQ 3)
            PUT " Active Membership As Of "
         ELSE
            PUT " Pending Members As Of "
         ENDIF
      ENDIF
      IF (%0 EQ 2)
         PUT " Recruiting Prospects As Of "
      ENDIF
      IF (%0 EQ 3)
         PUT " Pending Members As Of "
      ENDIF
      IF (%0 EQ 5)
         PUT " Inactive Membership As Of "
      ENDIF
      IF (%0 EQ 6)
         PUT " Veteran Membership As Of "
      ENDIF
      IF (%0 EQ 7)
         PUT " \034Mail Only\034 Membership As Of "
      ENDIF
      IF (%0 EQ 8)
         PUT " Historical Membership As Of "
      ENDIF
      PUT TODAY USING (MM/DD/YY)
      PUT "Page " AT 73
      PUT %7 USING (W2)
      PUT "\013\010\010"
      PRINT TO REPORT
      ASSIGN (%7 + 1) TO %7
      ASSIGN 4 TO %8
   ENDIF
   ASSIGN KEYBUF(1,1) TO $49

   PUT OFFICE                 # Line 1
   PUT LAST_NAME AT 6
   PUT FIRST_NAME AT 25
   PUT DOB USING (MM/DD/YY) AT 47
   IF (DEN GT 0)
      PUT "Den " AT 56
      PUT DEN
   ENDIF
   PUT "\013\010"
   PRINT TO REPORT

   PUT "H: " AT 8             # Line 2
   PUT HOME_PHONE
   ASSIGN ADDRA TO $0
   IF (SUBSTR(M_ADDRA,1,1) NE " ")
      ASSIGN M_ADDRA TO $0
   ENDIF
   PUT $0 AT 25
   IF (SUBSTR(SCHOOL,1,1) NE " ")
      PUT TRIM(SCHOOL) AT 56
   ENDIF
   PUT GRADE USING (BW1) AT 77
   ASSIGN RANK TO %1
   PUT RANK_LETTER(%1) AT 79
   PUT "\013\010"
   PRINT TO REPORT

   ASSIGN ADDRB TO $0         # Line 3/4
   IF (SUBSTR(M_ADDRB,1,1) NE " ")
      ASSIGN M_ADDRB TO $0
   ENDIF
   IF (SUBSTR($0,1,1) NE " ")
      PUT $0 AT 25
      PUT ID AT 56
      PUT "\013\010"
      PRINT TO REPORT
      ASSIGN (%8 + 1) TO %8
   ENDIF
   ASSIGN TRIM(CITY) TO $1
   IF (SUBSTR(M_CITY,1,1) NE " ")
      ASSIGN TRIM(M_CITY) TO $1
   ENDIF
   ASSIGN STATE TO $2
   IF (SUBSTR(M_STATE,1,1) NE " ")
      ASSIGN STATE TO $2
   ENDIF
   ASSIGN TRIM(ZIP) TO $3
   IF (SUBSTR(M_ZIP,1,1) NE " ")
      ASSIGN TRIM(M_ZIP) TO $3
   ENDIF
   PUT (((($1 CONCAT ", ") CONCAT $2) CONCAT "  ") CONCAT $3) AT 25
   IF (SUBSTR($0,1,1) EQ " ")
      PUT ID AT 56
   ENDIF
   PUT "\013\010"
   PRINT TO REPORT
   ASSIGN (%8 + 4) TO %8

   IF ((SUBSTR(HF_LAST_NAME,1,1) NE " ") OR (SUBSTR(HF_FIRST_NAME,1,1) NE " "))
      PUT "(" AT 25
      PUT TRIM(HF_FIRST_NAME)
      IF (SUBSTR(HF_LAST_NAME,1,1) NE " ")
         ASSIGN UPCASE(HF_LAST_NAME) TO $0
         ASSIGN INDEX(",",$0) TO %1
         IF (%1 GT 0)
            ASSIGN SUBSTR($0,1,%1 - 1) TO $0
            WHILE (LENGTH($0) LT 18)
               ASSIGN ($0 CONCAT " ") TO $0
            ENDWHILE
         ENDIF
         ASSIGN UPCASE(LAST_NAME) TO $1
         ASSIGN INDEX(",",$1) TO %1
         IF (%1 GT 0)
            ASSIGN SUBSTR($1,1,%1 - 1) TO $1
            WHILE (LENGTH($1) LT 18)
               ASSIGN ($1 CONCAT " ") TO $1
            ENDWHILE
         ENDIF
         IF ($1 NE $0)
            PUT (" " CONCAT TRIM(HF_LAST_NAME))
         ENDIF
      ENDIF
      ASSIGN (%8 + 1) TO %8
      PUT ")\013\010"
      PRINT TO REPORT
   ENDIF

   IF ((SUBSTR(HM_LAST_NAME,1,1) NE " ") OR (SUBSTR(HM_FIRST_NAME,1,1) NE " "))
      PUT "(" AT 25
      PUT TRIM(HM_FIRST_NAME)
      IF (SUBSTR(HM_LAST_NAME,1,1) NE " ")
         ASSIGN UPCASE(HM_LAST_NAME) TO $0
         ASSIGN INDEX(",",$0) TO %1
         IF (%1 GT 0)
            ASSIGN SUBSTR($0,1,%1 - 1) TO $0
            WHILE (LENGTH($0) LT 18)
               ASSIGN ($0 CONCAT " ") TO $0
            ENDWHILE
         ENDIF
         ASSIGN UPCASE(LAST_NAME) TO $1
         ASSIGN INDEX(",",$1) TO %1
         IF (%1 GT 0)
            ASSIGN SUBSTR($1,1,%1 - 1) TO $1
            WHILE (LENGTH($1) LT 18)
               ASSIGN ($1 CONCAT " ") TO $1
            ENDWHILE
         ENDIF
         IF ($1 NE $0)
            PUT (" " CONCAT TRIM(HM_LAST_NAME))
         ENDIF
      ENDIF
      ASSIGN (%8 + 1) TO %8
      PUT ")\013\010"
      PRINT TO REPORT
   ENDIF
   PUT "\010"
   PRINT TO REPORT

   NEXT KEY
   ASSIGN (%2 - 1) TO %2
ENDWHILE

IF (FILE_TYPE EQ 0)
   PUT "\026"
   PRINT TO REPORT
ENDIF
END
