**************************************************
* PRTJRN.CMD - V1.00 -
* PRINTS THE JOURNAL IN JOURNAL FORMAT
* CHOICES FOR SAVING AND PRINTING FILE
**************************************************
SET TALK OFF
STORE " " TO PRTANS
DO WHILE .NOT. PRTANS = "5"
STORE " " TO PRTANS
STORE 1 TO MRECNUM
STORE 0 TO MPAGE
STORE 0 TO MLASTREC
STORE 0 TO MLASTPG
STORE " " TO MNAME
STORE 0 TO MDR:SUM
STORE 0 TO MCR:SUM
STORE 1 TO MPAGREC
STORE " " TO MPRTJRN
ERASE
? CHR(07)
@ 2,10 SAY "******** FORMATTED PRINT MENU ********"
@ 4,1  SAY "SELECT ONE OF THE FOLLOWING:"
@ 6,1  SAY "1. SAVE OUTPUT FILE ON DISK ONLY."
@ 8,1  SAY "2. PRINT JOURNAL AND SAVE FILE."
@ 10,1 SAY "3. PRINT FORMATTED JOURNAL ONLY."
@ 12,1 SAY "4. PRINT JOURNAL FROM DISK FILE."
@ 14,1 SAY "5. RETURN TO INIT MENU."
@ 18,1 SAY "CAUTION: '3' WILL DESTROY OUTPUT FILE."
@ 19,10 SAY "OUTPUT FILE REQUIRES 2.5X"
@ 20,10 SAY "UNFORMATTED DISK SPACE."
@ 22,1 SAY " "
WAIT TO PRTANS
IF PRTANS = " " .OR. PRTANS = "5"
  DO AC101
ENDIF
***************** PRINT FROM DISK FILE ***********
IF PRTANS = "4"
  SET FORMAT TO PRINT
  SET PRINT ON
  USE B:PRTJRN
    LIST OFF
  SET FORMAT TO SCREEN
  SET PRINT OFF
  DO PRTJRN
ENDIF
****************************
IF .NOT. PRTANS = "4"
  USE PRTJRN
  COPY STRUCTURE TO B:PRTJRN
ENDIF
ERASE
****************** BEGIN PAGE LOOP ***************
USE B:GENJOURN
COUNT TO MLASTREC
GOTO 1
DO WHILE .NOT. EOF
STORE MPAGE + 1 TO MPAGE
****************** PRINT HEADER ******************
ERASE
@ 5,2 SAY " "
IF MHNAME = " "
  ACCEPT "TYPE HEADER NAME <CR>" TO MHNAME
ENDIF
IF MHYEAR = " "
  ACCEPT "TYPE HEADER YEAR <CR>" TO MHYEAR
ENDIF
IF MHQUART = " "
  ACCEPT "TYPE HEADER PERIOD <CR>" TO MHQUART
  STORE "GENERAL JOURNAL - PERIOD:" + MHQUART TO MHQUART
ENDIF
IF MHDATE = "00/00/001"
  ACCEPT "TYPE HEADER DATE (MM/DD/YY) <CR>" TO MHDATE
  STORE "DATE: " + MHDATE TO MHDATE
ENDIF
********
ERASE
USE B:PRTJRN
IF .NOT. PRTANS = "1"
  SET FORMAT TO PRINT
  SET PRINT ON
ENDIF
APPEND BLANK
  STORE "PAGE: " + STR(MPAGE,4,0) TO MHPAGE
  REPLACE FIELD1 WITH MHNAME
  REPLACE FIELD2 WITH MHPAGE
DISPLAY OFF
APPEND BLANK
  REPLACE FIELD1 WITH MHQUART
  REPLACE FIELD2 WITH MHDATE
DISPLAY OFF
APPEND BLANK
  REPLACE FIELD1 WITH MHYEAR
DISPLAY OFF
APPEND BLANK
DISPLAY OFF
APPEND BLANK
  STORE "---------+---------+---------+---------+---------+" TO MFLD1
  REPLACE FIELD1 WITH MFLD1
  STORE "---------+---------+" TO MFLD2
  REPLACE FIELD2 WITH MFLD2
DISPLAY OFF
APPEND BLANK
DISPLAY OFF
APPEND BLANK
  STORE "  ITEM  DATE      DESCRIPTION              A/N" TO MFLD1
  STORE "      Dr        Cr" TO MFLD2
  REPLACE FIELD1 WITH MFLD1
  REPLACE FIELD2 WITH MFLD2
DISPLAY OFF
APPEND BLANK
DISPLAY OFF
********** PRINT/REASSEMBLE RECORDS ****************
ERASE
IF PRTANS = "1"
  @ 10,10 SAY "TOTAL RECORDS:"
  @ 10,25 SAY MLASTREC
  @ 12,10 SAY "GETTING RECORD:"
  @ 14,1 SAY " "
ENDIF
***************** 10 RECORD PAGE LOOP **********************
STORE 0 TO MREGREC
STORE 0 TO MDR:SUM
STORE 0 TO MCR:SUM
  USE B:GENJOURN
  DO WHILE MREGREC < 40 .OR. (.NOT. EOF)
  USE B:GENJOURN
  GOTO MRECNUM
  IF PRTANS = "1"
    @ 12,25 SAY MRECNUM
  ENDIF
  STORE DATE TO MDATE
  STORE DR:DESCR TO MDR:DESCR
  STORE DR:AN TO MDR:AN
  STORE DR:AMT TO MDR:AMT
  STORE MDR:SUM + MDR:AMT TO MDR:SUM
  STORE "  " + CR:DESCR TO MCR:DESCR
  STORE CR:AN TO MCR:AN
  STORE CR:AMT TO MCR:AMT
  STORE MCR:SUM + MCR:AMT TO MCR:SUM
  STORE NOTES1 TO MNOTES1
  STORE NOTES2 TO MNOTES2
STORE " " TO MX
**************** SINGLE RECORD LOOP **************
USE B:PRTJRN
STORE 1 TO MRECLIN
DO WHILE MRECLIN <= 4
APPEND BLANK
STORE MREGREC + 1 TO MREGREC
STORE STR(MREGREC,3,0) TO MX
DO CASE
**************** 1ST LINE OF RECORD ***************
CASE MRECLIN = 1
  STORE MX + "     " + MDATE + "  " + MDR:DESCR + "     " + MDR:AN TO MFLD1
  STORE STR(MDR:AMT,10,2) TO MFLD2
**************** 2ND LINE OF RECORD ***************
CASE MRECLIN = 2
  STORE MX + "               " + MCR:DESCR + "   " + MCR:AN TO MFLD1
  STORE "          " + STR(MCR:AMT,10,2) TO MFLD2
**************** 3RD LINE OF RECORD ***************
CASE MRECLIN = 3
  STORE MX + "               " + MNOTES1 TO MFLD1
  STORE " " TO MFLD2
**************** 4TH LINE OF RECORD ***************
CASE MRECLIN = 4
  STORE MX + "               " + MNOTES2 TO MFLD1
  STORE " " TO MFLD2
ENDCASE
  REPLACE FIELD1 WITH MFLD1
  REPLACE FIELD2 WITH MFLD2
  STORE MRECLIN + 1 TO MRECLIN
DISPLAY OFF
LOOP
ENDDO
************** END OF RECORD LOOP ****************
STORE MRECNUM + 1 TO MRECNUM
IF MRECNUM > MLASTREC
  STORE "Y" TO MPRTJRN
  DO ADDREC
  ? CHR(12)
  SET FORMAT TO SCREEN
  SET PRINT OFF
  DO PRTJRN
ENDIF
LOOP
ENDDO
STORE "Y" TO MPRTJRN
DO ADDREC
************* END OF PAGE LOOP *******************
IF MRECNUM > MLASTREC
  STORE "Y" TO MPRTJRN
  DO ADDREC
  ? CHR(12)
  SET FORMAT TO SCREEN
  SET PRINT OFF
  DO PRTJRN
ENDIF
USE B:GENJOURN
GOTO MRECNUM
LOOP
ENDDO
LOOP
ENDDO
CANCEL