! AHA!  LABEL.BAS - prints up three across labels
! Ground Hog day, 1983   ske
!
Map1 input'file
       map2 lname,s,15
       map2 fname,s,12
       map2 company,s,30
       map2 street,s,30
       map2 city,s,15
       map2 state,s,2
       map2 zip,s,10
       map2 country,s,15

map1 label'counter,f
map1 name'bucket,s,15
map1 input'bucket,s,30
map1 DUMMY,s,1

strsiz 30
dim text$(5,3)


initialize:
       DUMMY = ""
       ? tab(-1,0); tab(10,10);
       input "do you need instructions? --> ", DUMMY
       if ucs(DUMMY) = "Y" &
           then &
               call INSTRUCTIONS
       open #1, "label.dat", input
       open #2, "label.lst", output
       ? tab(-1,0);
       ? tab(10,1); "Processing";

loop:
       label'counter = 0
       next'name:
           input line #1, name'bucket
           if eof(1) = 1 &
               then &
                   call flush :&
                   goto thats'all
           label'counter = label'counter + 1
           if name'bucket = "!" &
               then &
                   name'bucket = ""
           call read'rest'of'info
           ? ".";
           if label'counter = 3 &
               then &
                   call flush :&
                   goto loop &
               else &
                   goto next'name

thats'all:
       close #1
       close #2
       end

! ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

flush:
       call fix'blanks
       for n = 1 to 5
           for j = 1 to 3
               ? #2, tab(43 * (j-1)); text$(n,j);
               text$(n,j) = ""
           next j
           ? #2,
       next n
       ? #2,
       return

fix'blanks:
       for r = 1 to 2
          for n = 1 to 3
              for j = 5 to 2 step -1
                  if text$(j,n) = "" &
                      then &
                          text$(j,n) = text$(j-1,n) :&
                          text$(j-1,n) = ""
              next j
           next n
       next r
       return

read'rest'of'info:
       ! fname
       input'bucket = ""
       input line #1, input'bucket
       text$(1,label'counter) = input'bucket + " " + name'bucket

       ! company
       input'bucket = ""
       input line #1, input'bucket
       text$(2,label'counter) = input'bucket

       ! street
       input'bucket = ""
       input line #1, input'bucket
       text$(3,label'counter) = input'bucket

       ! city (and it's trailing comma)
       input'bucket = ""
       input line #1, input'bucket
       if input'bucket # "" &
           then &
               text$(4,label'counter) = input'bucket + ", "

       ! state
       input'bucket = ""
       input line #1, input'bucket
       text$(4,label'counter) = text$(4,label'counter) + input'bucket

       ! zip
       input'bucket = ""
       input line #1, input'bucket
       x = 22 - len(text$(4,label'counter))
       if x <= 0 &
           then &
               text$(4,label'counter) = text$(4,label'counter) + input'bucket &
           else &
               text$(4,label'counter) = text$(4,label'counter) + space(x) + input'bucket

       ! country
       input'bucket = ""
       input line #1, input'bucket
       text$(5,label'counter) = input'bucket

       ! trailing blank
       input line #1, input'bucket
       if eof(1) = 1 &
           then &
               call flush :&
               goto thats'all
       return

INSTRUCTIONS:
       ? tab(10,1); tab(-1,10); tab(10,19); "Label Formatter"
       ? tab(12,10); "This program formats three-up labels for people"
       ? tab(13,10); "you have SELECTed out of the AMUS Member File"
       ? tab(14,10); "To use this program, you must have said:"
       ? tab(15,10); "    OUTPUT SELECTED RECORDS USING FORMAT LABEL TO filename"
       ? tab(17,10); ".DAT is suggested for the filename. This program will"
       ? tab(18,10); "produce a file with the same name and the extension .LST"
       ? tab(19,10); "When this program is finished, you put labels in the printer"
       ? tab(20,10); "and PRINT out the file.LST"
       call PAUSE
       return

++include pause