!DATLNK.BAS 05/21/92 By Software Maintenance, Inc.
!
!
!
MAP1 IN'FILE,S,10
MAP1 X,F,6,0
MAP1 LINE'IN,S,80
MAP1 REC'CNT,F,6,0
MAP1 TOTAL'BYTES,F,6,0
MAP1 LINE'TOP,S,80
MAP1 BLK'LINE'FLAG,F,6,0
!
!
!CUSTOM.LNK represents a fairly constant listing of name and phone
!           numbers that I YANK into the end of my DART report.
!
!Before you can massage the DART report file you must remove all line feeds.
!
!
PRINT TAB(-1,0);
PRINT "Do not forget to append CUSTOM.LNK to DATLNK.*"
PRINT "Do not forget remove ^L form DATLNK.*"
INPUT LINE "Enter Input filename {DATLNK.*}: ";IN'FILE
    IN'FILE=UCS(IN'FILE)

    OPEN #2,IN'FILE,INPUT         !DART OUTPUT FILE
    OPEN #3,"LNKDFL.DAT",OUTPUT   !LINK FILE
    OPEN #4,"ADDAUD.LST",OUTPUT   !AUDIT FILE
!
    LINE'IN=SPACE(100)
    PRINT #3;"#400 Inventa"       !HEADER
!
GET'NEXT'LINE:
    PRINT ".";
    INPUT LINE #2,LINE'IN
    IF EOF(2) THEN GOTO END'PROG
    LINE'IN=UCS(LINE'IN)

!Begin check for blank lines.
!The "-" was chosen because of the layout of my DART report.  There always
!will be a key and a name.  The number of phone numbers would vary and this
!searches for the "-" in (215)-843-2900.
!
    X=INSTR(2,LINE'IN,"-")

!Blank line delimiting records from LNKDFL.LST
    IF (LINE'IN[X;1]<>"-" AND LINE'IN[X+1;1]=" ") THEN GOTO BLANK'LINE

!Empty data line
    IF (LINE'IN[X+2;1]=" " AND LINE'IN[X;1]="-")  GOTO GET'NEXT'LINE


!Calculate bytes
   TOTAL'BYTES=TOTAL'BYTES+LEN(LINE'IN)

!Write line to DAT file
   PRINT #3 UCS(LINE'IN);CHR$(13);

!Write to Audit trail file
   PRINT #4 LINE'IN

!Back Again
   GOTO GET'NEXT'LINE



END'PROG:
    CLOSE #2
    CLOSE #3
    CLOSE #4
    PRINT
    PRINT "TOTAL RECORDS ";REC'CNT;"TOTAL CHARACTERS ";TOTAL'BYTES
    PRINT "Datalink file: LNKDFL.DAT"
    PRINT "Audit    file: ADDAUD.LST"
    END
!
!
!If there is a blank line an End of Record flag needs to be written
BLANK'LINE:
    REC'CNT=REC'CNT+1
    PRINT #4
    PRINT #3 CHR$(00);CHR$(00);CHR$(00);CHR$(255);
    GOTO GET'NEXT'LINE

END