home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 5 / FreshFish_July-August1994.bin / bbs / biz / dfa-2.0.lha / DFA / Rexx / printlaserlabels.dfa < prev    next >
Text File  |  1994-04-04  |  11KB  |  429 lines

  1. /* $Revision Header built automatically *************** (do not edit) ************
  2. **
  3. ** © Copyright by Dirk Federlein
  4. **
  5. ** File             : printlaserlabels.dfa
  6. ** Created on       : Wednesday, 23.03.94 21:48:02
  7. ** Created by       : Dirk Federlein
  8. ** Current revision : V2.0
  9. **
  10. **
  11. ** Purpose
  12. ** -------
  13. **   - Prints 3-column laser labels of all selected ('>') addresses.
  14. **
  15. **   This script can be used without changes, if you use the following labels:
  16. **
  17. **            "Zweckform" No. 3669, 70 x 50.8 mm (15 labels/page)
  18. **
  19. **   If you prefer another label size, don't worry! It IS possible!
  20. **   All you have to do is to play around with the variables set in front of the
  21. **   line that starts with: "if ~show(ports ... ".
  22. **
  23. **   Please notice that the script tries to keep track of the current label
  24. **   position on the sheet. For this the environment variable 'DFA/SHEETOFFSET'
  25. **   is used.
  26. **
  27. **   The pages are written to files on the ram disk, named 'DFASheet_1.txt',
  28. **   'DFASheet_2.txt', 'DFASheet_3.txt', etc. depending on how many labels you are
  29. **   printing. These files are then copied to the printer, if you wish this.
  30. **
  31. **   Please notice: Some laser printers (e.g. HP Laserjet IV) seem to remove
  32. **   leading carriage returns in the beginning of the page. As I don't have
  33. **   such a printer, I cannot test it by myself, but I assume that replacing
  34. **   (cr) by (space) (cr) could solve the problem.
  35. **
  36. **
  37. ** Revision V2.0
  38. ** --------------
  39. ** created on Wednesday, 23.03.94 21:48:02  by  Dirk Federlein.   LogMessage :
  40. **     --- Initial release ---
  41. **
  42. *********************************************************************************/
  43.  
  44. options results
  45.  
  46. cr        = '0A'X
  47. space    = ' '
  48.  
  49. outbody        = 'RAM:DFASheet_'
  50. outext        = '.txt'
  51.  
  52. labelspercol    = 5
  53. labelsperrow    = 3
  54. labelspersheet    = labelspercol * labelsperrow
  55.  
  56. linesperlabel    = 10    /* Each label has up to xx lines                             */
  57. linesfromtop    = 3        /* Additional lines counted from the very top of every label */
  58. colsperlabel    = 33    /* Number of chars the fit on one label                      */
  59.  
  60. labeloffset        = 6        /* Space from left edge that shall be empty                  */
  61.  
  62.  
  63. if ~show(ports, DFA) then
  64.     exit 10
  65.  
  66. if open('envhandle', 'ENV:DFA/SHEETOFFSET', 'R') then
  67. do
  68.     lnumber = readln('envhandle')
  69.  
  70.     if lnumber > labelspersheet then
  71.         lnumber = 1
  72.  
  73.     if lnumber < 1 then
  74.         lnumber = 1
  75.  
  76.     /* Must be like below to close the file REALLY */
  77.  
  78.     call close 'envhandle'
  79. end
  80. else
  81. do
  82.     lnumber    = 1
  83.  
  84.     address command 'setenv' 'DFA/SHEETOFFSET' lnumber
  85.     address command 'copy' 'Env:DFA/SHEETOFFSET' 'ENVARC:DFA'
  86.  
  87. end
  88.  
  89. sheetnum = 1
  90.  
  91. outname    = outbody||sheetnum||outext
  92.  
  93.  
  94. if open('outfile', outname, 'W') = 0 then
  95. do
  96.     exit 10
  97. end
  98. else
  99. do
  100.  
  101.     row        = (lnumber-1) % labelsperrow
  102.  
  103.     if row > 0 then
  104.     do
  105.         /* --- insert rows... ------------------------------------------- */
  106.  
  107.         crnum    = row * linesperlabel
  108.  
  109.         do i = 1 to crnum
  110.             numchars = writech('outfile', cr)
  111.         end
  112.     end
  113.  
  114.     /* --- Clear buffers ------------------------------------------------ */
  115.  
  116.     col        = (lnumber-1) // labelsperrow        /* modulo */
  117.  
  118.     adr1.0    = ""
  119.     adr1.1    = ""
  120.     adr1.2    = ""
  121.     adr1.3    = ""
  122.     adr1.4    = ""
  123.     adr1.5    = ""
  124.     adr1.6    = ""
  125.  
  126.     adr2.0    = ""
  127.     adr2.1    = ""
  128.     adr2.2    = ""
  129.     adr2.3    = ""
  130.     adr2.4    = ""
  131.     adr2.5    = ""
  132.     adr2.6    = ""
  133.  
  134.     adr3.0    = ""
  135.     adr3.1    = ""
  136.     adr3.2    = ""
  137.     adr3.3    = ""
  138.     adr3.4    = ""
  139.     adr3.5    = ""
  140.     adr3.6    = ""
  141.  
  142.     currentcol    = col+1
  143.     currentrow    = row+1
  144.  
  145.  
  146.     FIRST STEM ADR.
  147.  
  148.     if ADR.ADDRESS.24 = 0 then
  149.         NEXTSEL STEM ADR.
  150.  
  151.     do while RC = 0
  152.  
  153.         if currentcol = 1 then
  154.         do
  155.             adr1.0    = "An"
  156.             adr1.1    = ADR.ADDRESS.0
  157.             adr1.2    = ADR.ADDRESS.1 ADR.ADDRESS.2
  158.             adr1.3    = ADR.ADDRESS.3
  159.             adr1.4    = ADR.ADDRESS.4
  160.             adr1.5    = ADR.ADDRESS.5 ADR.ADDRESS.6||', '||ADR.ADDRESS.7
  161.             adr1.6    = ADR.ADDRESS.8
  162.         end
  163.  
  164.         if currentcol = 2 then
  165.         do
  166.             adr2.0    = "An"
  167.             adr2.1    = ADR.ADDRESS.0
  168.             adr2.2    = ADR.ADDRESS.1 ADR.ADDRESS.2
  169.             adr2.3    = ADR.ADDRESS.3
  170.             adr2.4    = ADR.ADDRESS.4
  171.             adr2.5    = ADR.ADDRESS.5 ADR.ADDRESS.6||', '||ADR.ADDRESS.7
  172.             adr2.6    = ADR.ADDRESS.8
  173.         end
  174.  
  175.         if currentcol = 3 then
  176.         do
  177.             adr3.0    = "An"
  178.             adr3.1    = ADR.ADDRESS.0
  179.             adr3.2    = ADR.ADDRESS.1 ADR.ADDRESS.2
  180.             adr3.3    = ADR.ADDRESS.3
  181.             adr3.4    = ADR.ADDRESS.4
  182.             adr3.5    = ADR.ADDRESS.5 ADR.ADDRESS.6||', '||ADR.ADDRESS.7
  183.             adr3.6    = ADR.ADDRESS.8
  184.  
  185.             /* --- Now we have to format each line an write it to the file  */
  186.  
  187.             do i = 1 to linesfromtop
  188.                 numchars = writech('outfile', cr)
  189.             end
  190.  
  191.             linebuffer    = copies(' ', labeloffset)
  192.             linebuffer = insert(adr1.0, linebuffer, labeloffset, colsperlabel)
  193.             linebuffer = insert(adr2.0, linebuffer, colsperlabel+labeloffset, colsperlabel)
  194.             linebuffer = linebuffer||' '||adr3.0
  195.  
  196.             numchars = writech('outfile', linebuffer cr)
  197.  
  198.             linebuffer    = copies(' ', labeloffset)
  199.             linebuffer = insert(adr1.1, linebuffer, labeloffset, colsperlabel)
  200.             linebuffer = insert(adr2.1, linebuffer, colsperlabel+labeloffset, colsperlabel)
  201.             linebuffer = linebuffer||' '||adr3.1
  202.  
  203.             numchars = writech('outfile', linebuffer cr)
  204.  
  205.             linebuffer    = copies(' ', labeloffset)
  206.             linebuffer = insert(adr1.2, linebuffer, labeloffset, colsperlabel)
  207.             linebuffer = insert(adr2.2, linebuffer, colsperlabel+labeloffset, colsperlabel)
  208.             linebuffer = linebuffer||' '||adr3.2
  209.  
  210.             numchars = writech('outfile', linebuffer cr)
  211.  
  212.             linebuffer    = copies(' ', labeloffset)
  213.             linebuffer = insert(adr1.3, linebuffer, labeloffset, colsperlabel)
  214.             linebuffer = insert(adr2.3, linebuffer, colsperlabel+labeloffset, colsperlabel)
  215.             linebuffer = linebuffer||' '||adr3.3
  216.  
  217.             numchars = writech('outfile', linebuffer cr)
  218.  
  219.             linebuffer    = copies(' ', labeloffset)
  220.             linebuffer = insert(adr1.4, linebuffer, labeloffset, colsperlabel)
  221.             linebuffer = insert(adr2.4, linebuffer, colsperlabel+labeloffset, colsperlabel)
  222.             linebuffer = linebuffer||' '||adr3.4
  223.  
  224.             numchars = writech('outfile', linebuffer cr)
  225.  
  226.             linebuffer    = copies(' ', labeloffset)
  227.             linebuffer = insert(adr1.5, linebuffer, labeloffset, colsperlabel)
  228.             linebuffer = insert(adr2.5, linebuffer, colsperlabel+labeloffset, colsperlabel)
  229.             linebuffer = linebuffer||' '||adr3.5
  230.  
  231.             numchars = writech('outfile', linebuffer cr)
  232.  
  233.             linebuffer    = copies(' ', labeloffset)
  234.             linebuffer = insert(adr1.6, linebuffer, labeloffset, colsperlabel)
  235.             linebuffer = insert(adr2.6, linebuffer, colsperlabel+labeloffset, colsperlabel)
  236.             linebuffer = linebuffer||' '||adr3.6
  237.  
  238.             numchars = writech('outfile', linebuffer cr)
  239.  
  240.             do i = 1 to linesperlabel - 7
  241.                 numchars = writech('outfile', cr)
  242.             end
  243.  
  244.             /* --- Clear alread written buffers ------------------------- */
  245.  
  246.             adr1.0    = ""
  247.             adr1.1    = ""
  248.             adr1.2    = ""
  249.             adr1.3    = ""
  250.             adr1.4    = ""
  251.             adr1.5    = ""
  252.             adr1.6    = ""
  253.  
  254.             adr2.0    = ""
  255.             adr2.1    = ""
  256.             adr2.2    = ""
  257.             adr2.3    = ""
  258.             adr2.4    = ""
  259.             adr2.5    = ""
  260.             adr2.6    = ""
  261.  
  262.             adr3.0    = ""
  263.             adr3.1    = ""
  264.             adr3.2    = ""
  265.             adr3.3    = ""
  266.             adr3.4    = ""
  267.             adr3.5    = ""
  268.             adr3.6    = ""
  269.  
  270.             currentrow = currentrow + 1
  271.  
  272.         end
  273.  
  274.         if currentcol = labelsperrow then
  275.             currentcol = 1
  276.         else
  277.             currentcol = currentcol+1
  278.  
  279.         if currentrow = (labelspercol+1) then
  280.             currentrow = 1
  281.  
  282.         lnumber        = lnumber + 1
  283.  
  284.         /* --- New page: new file ------------------------------------------- */
  285.  
  286.         if lnumber >= labelspersheet+1 then
  287.         do
  288.             lnumber = 1
  289.  
  290.             close('outfile')
  291.  
  292.             sheetnum = sheetnum + 1
  293.  
  294.             outname    = outbody||sheetnum||outext
  295.  
  296.             if open('outfile', outname, 'W') = 0 then
  297.             do
  298.                 exit 10
  299.             end
  300.  
  301.         end
  302.  
  303.         /* --- Update env var ----------------------------------------------- */
  304.  
  305.         address command 'setenv' 'DFA/SHEETOFFSET' lnumber
  306.  
  307.         address command 'copy' 'Env:DFA/SHEETOFFSET' 'ENVARC:DFA/SHEETOFFSET'
  308.  
  309.         nextsel STEM ADR.
  310.  
  311.     end
  312.  
  313.     /* --- If a partial line is kept, write it now ---------------------- */
  314.  
  315.     if currentcol > 1 then
  316.     do
  317.         do i = 1 to linesfromtop
  318.             numchars = writech('outfile', cr)
  319.         end
  320.  
  321.         linebuffer    = copies(' ', labeloffset)
  322.         linebuffer = insert(adr1.0, linebuffer, labeloffset, colsperlabel)
  323.         linebuffer = insert(adr2.0, linebuffer, colsperlabel+labeloffset, colsperlabel)
  324.         linebuffer = linebuffer||' '||adr3.0
  325.  
  326.         numchars = writech('outfile', linebuffer cr)
  327.  
  328.         linebuffer    = copies(' ', labeloffset)
  329.         linebuffer = insert(adr1.1, linebuffer, labeloffset, colsperlabel)
  330.         linebuffer = insert(adr2.1, linebuffer,