/* $Revision Header built automatically *************** (do not edit) ************ ** ** © Copyright by Dirk Federlein ** ** File : FiloFaxTeX.dfa ** Created on : Dienstag, 25.10.94 21:40:03 ** Created by : Dirk Federlein ** Current revision : V1.0 ** ** ** Purpose ** ------- ** Outputs one or more ASCII files, each containing 4 DinA6 pages ** with formatted addresses. ** ** Adresses with another starting letter with the predecessors get a new ** page. ** ** The pages may be copied to the printer (prt:/par:) using the usual copy ** command. ** ** Each A4-page contains 96x84 chars. ** ** This script needs DFA v2.5 and above to run properly. ** *********************************************************************************/ tabchar = '09'X cr = '0A'X outbody = 'RAM:DFASheet_' outext = '.txt' options results if ~show(ports, DFA) then exit 10 address "DFA" /* Init "page" 1 */ page1. = "" /* Init page #2 */ page2. = "" /* Init page #3 */ page3. = "" /* Init page #4 */ page4. = "" /* Clear address buffer */ tmpadr.0 = "" /* First Name / Name */ tmpadr.1 = "" /* Street */ tmpadr.2 = "" /* ZIP City */ tmpadr.3 = "" /* Phone */ tmpadr.4 = "" /* Fax. - if available */ tmpadr.5 = "" /* Comment - if available */ pageitems = 0 pagelines = 0 pagenum = 1 currentline = 0 maxpagelines = 40 /* Max. lines per (A6) page */ leftoffset = 8 /* left offset */ maxlinelen = 46 /* Max. chars per (A6) line */ pageskip = 5 /* Skip between the upper and the lower 2 A6 pages */ skipnext = 0 sheetnum = 1 outname = outbody||sheetnum||outext gui input off output off FIRST STEM ADR. CurrentLetter = left(ADR.ADDRESS.2,1) LastLetter = left(ADR.ADDRESS.2,1) do while RC = 0 /* Init all strings... */ tmpadr. = "" ready = 0 adritem = 0 fmtline = 0 do while ready = 0 /* */ if adritem = 1 then do if ADR.ADDRESS.adritem ~= "" then tmpadr.fmtline = ADR.ADDRESS.adritem end /* */ if adritem = 2 then do if ADR.ADDRESS.adritem ~= "" then do if tmpadr.fmtline ~= "" then tmpadr.fmtline = tmpadr.fmtline ADR.ADDRESS.adritem else tmpadr.fmtline = ADR.ADDRESS.adritem end if tmpadr.fmtline ~= "" then fmtline = fmtline+1 end /* */ if adritem = 4 then do if ADR.ADDRESS.adritem ~= "" then do tmpadr.fmtline = ADR.ADDRESS.adritem fmtline = fmtline+1 end end /* */ if adritem = 5 then do if ADR.ADDRESS.adritem ~= "" then tmpadr.fmtline = ADR.ADDRESS.adritem end /* */ if adritem = 6 then do if ADR.ADDRESS.adritem ~= "" then do if tmpadr.fmtline ~= "" then tmpadr.fmtline = tmpadr.fmtline ADR.ADDRESS.adritem else tmpadr.fmtline = ADR.ADDRESS.adritem end if tmpadr.fmtline ~= "" then fmtline = fmtline+1 end /* */ if adritem = 8 then do if ADR.ADDRESS.adritem ~= "" then do if (index(UPPER(ADR.ADDRESS.adritem), "GERMANY") == 0) & (index(UPPER(ADR.ADDRESS.adritem), "DEUTSCHLAND") == 0) then do tmpadr.fmtline = ADR.ADDRESS.adritem fmtline = fmtline+1 end end end /* */ if adritem = 10 then do if ADR.ADDRESS.adritem ~= "" then do if index(ADR.ADDRESS.adritem, "|") = 0 then do tmpadr.fmtline = "Tel." ADR.ADDRESS.adritem fmtline = fmtline+1 end else do phonecnt = 0 /* START...'|' */ phonecnt = index(ADR.ADDRESS.adritem, "|") tmpadr.fmtline = "Tel." left(ADR.ADDRESS.adritem,phonecnt-1) fmtline = fmtline+1 phonecnt = phonecnt + 1 nextcnt = 0 do while index(ADR.ADDRESS.adritem, "|", phonecnt) ~= 0 nextcnt = index(ADR.ADDRESS.adritem, "|", phonecnt) tmpadr.fmtline = " " substr(ADR.ADDRESS.adritem, phonecnt, nextcnt-phonecnt) fmtline = fmtline+1 phonecnt = nextcnt+1 end /* '|'...END */ tmpadr.fmtline = " " right(ADR.ADDRESS.adritem, LENGTH(ADR.ADDRESS.adritem)-phonecnt+1) fmtline = fmtline+1 end end end /* */ if adritem = 11 then do if ADR.ADDRESS.adritem ~= "" then do if index(ADR.ADDRESS.adritem, "|") = 0 then do tmpadr.fmtline = "Fax." ADR.ADDRESS.adritem fmtline = fmtline+1 end else do phonecnt = 0 /* START...'|' */ phonecnt = index(ADR.ADDRESS.adritem, "|") tmpadr.fmtline = "Fax." left(ADR.ADDRESS.adritem,phonecnt-1) fmtline = fmtline+1 phonecnt = phonecnt + 1 nextcnt = 0 do while index(ADR.ADDRESS.adritem, "|", phonecnt) ~= 0 nextcnt = index(ADR.ADDRESS.adritem, "|", phonecnt) tmpadr.fmtline = " " substr(ADR.ADDRESS.adritem, phonecnt, nextcnt-phonecnt) fmtline = fmtline+1 phonecnt = nextcnt+1 end /* '|'...END */ tmpadr.fmtline = " " right(ADR.ADDRESS.adritem, LENGTH(ADR.ADDRESS.adritem)-phonecnt+1) fmtline = fmtline+1 end end end /* */ if adritem = 15 then do if ADR.ADDRESS.adritem ~= "" then do tmpadr.fmtline = ADR.ADDRESS.adritem fmtline = fmtline+1 end end /* Process next address item... */ adritem = adritem+1 /* Last item reached ? */ if adritem>15 then ready = 1 end addresslines = fmtline+1 /* fmtline count starts with zero */ if CurrentLetter ~= LastLetter then do /* Fill empty lines of page 1 and page 3 */ if pagenum = 1 then do i = currentline do while i < maxpagelines page1.i = INSERT(" ", page1.i, leftoffset, maxlinelen, " ") i = i+1 end end if pagenum = 3 then do i = currentline do while i < maxpagelines page3.i = INSERT(" ", page3.i, leftoffset, maxlinelen, " ") i = i+1 end end pagenum = pagenum + 1 if pagenum > 4 then do /* Output all 4 pages... */ if open('outfile', outname, 'W') = 0 then do gui input on output on exit 10 end else do i = 0 do while i < maxpagelines numchars = writech('outfile', page1.i page2.i (cr)) i = i+1 end i = 0 do while i < pageskip numchars = writech('outfile', (cr)) i = i+1 end i = 0 do while i < maxpagelines numchars = writech('outfile', page3.i page4.i (cr)) i = i+1 end call close 'outfile' sheetnum = sheetnum + 1 outname = outbody||sheetnum||outext end currentline = 0 pagenum = 1 page1. = "" page2. = "" page3. = "" page4. = "" end pageitems = 0 currentline = 0 end pageitems = pageitems + 1 if pagenum = 1 then do if (currentline + addresslines - 1) < maxpagelines then do linecnt = 0 do while linecnt <= fmtline if tmpadr.linecnt ~= "" then do page1.currentline = INSERT(tmpadr.linecnt, page1.currentline, leftoffset, maxlinelen, " ") currentline = currentline + 1 end linecnt = linecnt + 1 end page1.currentline = INSERT(" ", page1.currentline, leftoffset, maxlinelen, " ") currentline = currentline +1 end else do currentline = 0 pageitems = 0 pagenum = 2 end end if pagenum = 2 then do if (currentline + addresslines - 1) < maxpagelines then do linecnt = 0 do while linecnt <= fmtline if tmpadr.linecnt ~= "" then do page2.currentline = INSERT(tmpadr.linecnt, page2.currentline, leftoffset, maxlinelen, " ") currentline = currentline + 1 end linecnt = linecnt + 1 end page2.currentline = INSERT(" ", page2.currentline, leftoffset, maxlinelen, " ") currentline = currentline +1 end else do pagenum = 3 pageitems = 0 currentline = 0 end end if pagenum = 3 then do if (currentline + addresslines - 1) < maxpagelines then do linecnt = 0 do while linecnt <= fmtline if tmpadr.linecnt ~= "" then do page3.currentline = INSERT(tmpadr.linecnt, page3.currentline, leftoffset, maxlinelen, " ") currentline = currentline + 1 end linecnt = linecnt + 1 end page3.currentline = INSERT(" ", page3.currentline, leftoffset, maxlinelen, " ") currentline = currentline +1 end else do pagenum = 4 pageitems = 0 currentline = 0 end end if pagenum = 4 then do if (currentline + addresslines - 1) < maxpagelines then do linecnt = 0 do while linecnt <= fmtline if tmpadr.linecnt ~= "" then do page4.currentline = INSERT(tmpadr.linecnt, page4.currentline, leftoffset, maxlinelen, " ") currentline = currentline + 1 end linecnt = linecnt + 1 end page4.currentline = INSERT(" ", page4.currentline, leftoffset, maxlinelen, " ") currentline = currentline +1 end else do /* Output this page to file...*/ if open('outfile', outname, 'W') = 0 then do gui input on output on exit 10 end else do i = 0 do while i < maxpagelines numchars = writech('outfile', page1.i page2.i (cr)) i = i+1 end i = 0 do while i < pageskip numchars = writech('outfile', (cr)) i=i+1 end i = 0 do while i < maxpagelines numchars = writech('outfile', page3.i page4.i (cr)) i = i+1 end call close 'outfile' sheetnum = sheetnum + 1 outname = outbody||sheetnum||outext end currentline = 0 pageitems = 0 pagenum = 1 skipnext = 1 page1. = "" page2. = "" page3. = "" page4. = "" end end if skipnext = 0 then do next stem adr. LastLetter = CurrentLetter CurrentLetter = left(ADR.ADDRESS.2,1) end else skipnext = 0 end if (pageitems > 0) | (pagenum > 1) then do /* Output all 4 pages... */ if open('outfile', outname, 'W') = 0 then do gui input on output on exit 10 end else do /* Fill empty lines of page 1 and page 3 */ i = currentline if pagenum = 1 then do do while i < maxpagelines page1.i = INSERT(" ", page1.i, leftoffset, maxlinelen, " ") i = i+1 end end if pagenum = 3 then do do while i < maxpagelines page3.i = INSERT(" ", page3.i, leftoffset, maxlinelen, " ") i = i+1 end end i = 0 do while i < maxpagelines numchars = writech('outfile', page1.i page2.i (cr)) i = i+1 end i = 0 do while i < pageskip numchars = writech('outfile', (cr)) i=i+1 end i = 0 do while i < maxpagelines numchars = writech('outfile', page3.i page4.i (cr)) i = i+1 end call close 'outfile' end end gui input on output on exit