1 ! & ! OUTCNV Ver 1.00 15-Oct-88 00:45:35 & ! By Anders Gripsborn & ! & ! It converts "NETNWS.KUT" to & ! individual texts "NET:Kxxxxx.INT" & ! & ! Format of "NETNWS.KUT": & ! & ! Alla texts begin with six chr$(25%) & ! and ends with six chr$(24%). & ! & ! The file is terminated with six & ! chr$(26%). & ! & ! Each text contains of: & ! Id = "Texnumber/Groupnumber" from KOM. & ! Internet name of author . & ! The very same's KOM name. & ! Date of origin. & ! All outher headerlines. & ! One empty line. & ! Therafter the text. & ! & 300 dim header$(500%) ! Maximum number of header lines & \ dim receiver$(200%) ! Maximum number of receivers & 1000 on error goto 19000 & \ print "OUTCNV"; & 1010 open "SY:NETNWS.KUT" for input as file 12% & \ beg$=string$(6%,25%) & \ eot$=string$(6%,24%) & \ eof$=string$(6%,26%) & \ komadr$="@ufh.dynas.se" & \ utdev$="NET:" & \ fil% = 0% \ nrf% = 0% & 1015 open utdev$+"NETNWS.DAT" for input as file 1% & \ input #1%, fil% & \ close 1% & 1020 while -1% & \ a$=fngtlin$ until a$ == beg$ or a$==eof$ & \ goto 7000 if a$ == eof$ & \ id$ = fngtlin$ & \ usnam$ = fngtlin$ & \ nam$ = fngtlin$ & \ datum$ = fncnvdate$(fngtlin$) & \ from$ = "From: "+usnam$+komadr$+" ("+nam$+")" & \ rece% = 0% \ header% = 0% & \ receP% = 0% & \ while -1% & \ a$ = fngtlin$ & \ goto 1560 unless len(a$) & \ goto 1535 if (receP% and (left(a$,1%) = " ")) & \ goto 1540 unless left(a$,4%) = "To: " & \ receP% = -1% & \ a$ = right(a$, 4%) 1535 rece% = rece% + 1% & \ a$ = left(a$,len(a$)-1%) if & right(a$,len(a$)) = "," & \ receiver$(rece%) = cvt$$(a$, 8%) & \ goto 1550 1540 receP% = 0% & \ header% = header% +1% & \ header$(header%) = a$ 1550 next & 1560 subj$ = fngtlin$ & \ goto 5000 if a$ == eot$ & \ subj$ = "Subject: "+fnsubhed$(subj$) & \ goto 5000 if rece% = 0% & \ goto 1600 unless rece% > 11% & \ inio% = 11% \ recpos% = 1% & \ open "outcnv.tmp" for output as file inio% & \ until a$ == eot$ & \ a$ = fngtlin$ & \ print #inio%, a$ & \ next & \ close inio% & \ recpos% = 1% & \ while rece% > 0% & \ open"outcnv.tmp" for input as file inio% & \ sl% = fnmin%(rece%, 10%) & \ gosub 10000 & \ rece% = rece% - 10% & \ next & \ kill "outcnv.tmp" & \ goto 1610 & 1600 recpos% = 1% \ sl% = rece% & \ inio% = 12% & \ gosub 10000 & 1610 next & 5000 print \ print & \ print "%Illigal text format. (Text-Id: "+id$+")" & \ print \ print "OUTCNV"; & \ goto 1020 & 7000 print ": "+num1$(nrf%)+" text"; & \ print "s"; unless nrf% = 1% & \ print " converted." & \ open utdev$+"NETNWS.DAT" for output as file 1% & \ print #1%, fil% & \ close 1%, 12% & \ goto 32767 & 10000 ! & ! Subroutine that saves a text on & ! files 1 to sl%. It takes input from & ! inio%. & ! recpos% = pointer in reciver$ & ! & 10010 for io% = 1% to sl% & \ fil% = fil% + 1 \ nrf% = nrf% + 1% & \ a$ = left(num1$(fil%),5%) & \ a$ = "K"+string$(5%-len(a$),ascii("0"))+a$+".INT" & \ open utdev$+a$ for output as file io% & \ print #io%, fnstrip$(receiver$(recpos%)) & \ print #io%, "From "+usnam$+" "+datum$+" remote from ufh" & \ print #io%, "Date: "+datum$ & \ print #io%, "Message-Id: " & \ print #io%, "To: "+receiver$(recpos%) & \ print #io%, from$ & \ print #io%, "Return-Path: "+usnam$+komadr$ & \ print #io%, header$(h%) for h% = 1% to header% & \ print #io%, subj$ & \ print #io% & \ recpos% = recpos% + 1% & \ next io% & \ a$ = fngetlin$(inio%) & \ until a$ == eot$ & \ print #io%, a$ for io% = 1% to sl% & \ a$ = fngetlin$(inio%) & \ next & \ close io% for io% = 1% to sl% & \ return & 15000 def* fngtlin$ = fngetlin$(12%) & 15005 def* fngetlin$(io%) & \ input line #io%, a.gt$ & \ fngetlin$=left(a.gt$,len(a.gt$)-2%) & \ fnend & 15010 def* fncnvdate$(a$) = fnrepl$(fnrepl$(a$,"-"," "),",","")+" MET" & 15050 def* fnrepl$(a$,b$,c$) & \ a.rep% = 1% & \ while a.rep% & \ a.rep% = instr(a%, a$, b$) & \ goto 15060 unless a.rep% & \ a$ = left(a$, a.rep%-1%)+c$ & + right(a$, a.rep%+len(b$)) & \ a.rep% = a.rep%+len(c$) & \ next 15060 fnrepl$ = a$ & \ fnend & 15070 def* fnstrip$(a$) & \ a.st% = instr(1%, a$, "<") & \ goto 15075 unless a.st% & \ a$ = right(a$, a.st%+1%) & \ a.st% = instr(1%, a$, ">") & \ a$ = left(a$, a.st%-1%) if a.st% 15075 len.st% = len(a$) \ c.st$ = " " & \ a.st$ = "" \ nr.st% = 0% & \ for i.st% = 1% to len.st% & \ lset c.st$ = mid(a$, i.st%, 1%) & \ if c.st$ = "(" then nr.st% = nr.st% + 1% else & if c.st$ = ")" then nr.st% = nr.st% - 1% else & a.st$ = a.st$+c.st$ unless nr.st% or c.st$ = " " 15080 next i.st% & \ fnstrip$ = a.st$ & \ fnend & 15090 def* fnmin%(a%,b%) & \ if a% < b% then fnmin% = a% else fnmin% = b% 15100 fnend & 15110 def* fnsubhed$(a$) & \ a.su% = instr(1%, a$, ":") & \ if a.su% = 0% then fnsubhed$ = a$ else & b.su% = instr(1%, a$, " ") & \ if b.su% < a.su% then fnsubhed$ = a$ else & fnsubhed$ = right(a$, a.su%+1%) 15120 fnend & 19000 if erl = 1010 or err = 11 then resume 7000 else & if erl = 1015 and err = 5 then resume 1020 else & on error goto 0 & 32000 goto 1000 ! C C L - E n t r y & 32767 end