home *** CD-ROM | disk | FTP | other *** search
/ CP/M / CPM_CDROM.iso / simtel / sigm / vols000 / vol064 / label.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1984-04-29  |  3.5 KB  |  119 lines

  1. PROGRAM STICKERS;{$P}
  2. {$C-,M-,F-}
  3.  
  4. CONST
  5. SPACE = '           ';   {11 spaces-- horizontal distance between end of}
  6.                          {line and next label on form-feed label sheet}
  7. TYPE
  8. BYTE = 0..255;
  9. $STRING255 = STRING 255;
  10. $STRING80 = STRING 80;
  11. $STRING0 = STRING 0;
  12. $STRING35 = STRING 35; 
  13.  
  14.  
  15. VAR
  16. ACROSS,TOP_MARGIN,BOTTOM_MARGIN,GAP,WIDTH,HEIGHT,SPACING,COUNTER,NUMBER,I:BYTE;
  17. NUM:REAL;
  18. LINE:ARRAY[1..4] OF $STRING35;
  19. FOUT:TEXT;
  20. CONTINUE:CHAR;
  21. ERROR:BOOLEAN;
  22.  
  23. FUNCTION LENGTH(X:$STRING255):INTEGER;EXTERNAL;
  24. PROCEDURE SETLENGTH(VAR X:$STRING0; Y:INTEGER);EXTERNAL;
  25.  
  26.  
  27. BEGIN
  28. FOR I:= 1 TO 4 DO SETLENGTH(LINE[I],0);
  29.  
  30. REWRITE ('LST:',FOUT);
  31. WRITELN(CHR(27),'*',CHR(0),CHR(0),CHR(0),CHR(0)); {clear screen}
  32.  
  33. writeln('enter a "1" if there is a single label per "line", and a ');
  34. write('         "3" if there are 3 labels per "line":  ');
  35. repeat
  36. read(SPACING);
  37. until SPACING  in [1,3]; {allow either 1 or 3 labels across only, since}
  38.                        {these are the most commonly found form-feed labels}
  39. ERROR:=FALSE;
  40. REPEAT
  41. writeln;
  42. writeln;
  43. write('enter the width of the label in number of characters: ');
  44. readln(WIDTH);
  45. writeln;
  46. writeln;
  47. writeln('enter the total number of vertical lines per label measured from ');
  48. write(' the top to the bottom of the label: ');
  49. READLN(HEIGHT);  {SOME LABELS HAVE A GREATER HEIGHT THAN OTHERS}
  50. WRITELN;
  51. writeln;
  52. writeln('the total: top margin + bottom margin + 4 must be < or = the ');  
  53. writeln('total number of vertical lines per label... remebering this, ');
  54. writeln;
  55. write('enter the number of lines you wish left at top of label as margin:  ');
  56. readln(TOP_MARGIN);
  57. writeln;
  58. writeln;
  59. write('enter the # of lines you wish left at bottom of label as margin:  ');
  60. readln(BOTTOM_MARGIN);
  61. if HEIGHT < (top_margin + bottom_margin + 4) then error := true;
  62. if error = true then writeln('ERROR IN MEASUREMENT.  PLEASE RE-ENTER.  ');
  63. UNTIL ERROR = FALSE;
  64.  
  65. write('enter the number of lines between labels, i.e. the gap: ');
  66. readln(gap);
  67. writeln;
  68. writeln; 
  69.  
  70. WRITE('ENTER THE NUMBER OF LABELS YOU NEED:  ');
  71. READLN(NUM);
  72. CASE SPACING OF 
  73. 1: NUMBER:=ROUND(NUM);
  74. 3:BEGIN
  75. NUMBER:=ROUND(NUM/3.0); {there are three labels across "line" of the sheet}
  76. If (Num/3.0  - number) > 0 then number:=number + 1;
  77. END;    {i.e err on side of printing too many lines of labels}
  78. END; {OF CASE}
  79.  
  80. WRITELN(CHR(27),'*',CHR(0),CHR(0),CHR(0),CHR(0));
  81.  
  82. writeln('NOTE: MAXIMUM LENGTH OF ANY LINE IS ',WIDTH-5:3,' CHARACTERS! ');
  83. WRITELN;
  84. WRITELN;
  85.  
  86. FOR I:= 1 TO 4 DO 
  87.     BEGIN
  88.     WRITELN('ENTER LINE NUMBER:  ',I:2,'  ');
  89.     READLN(LINE[I]);
  90.     END;
  91.  
  92. FOR I:= 1 TO 4 DO 
  93.     IF (LENGTH(LINE[I]) > (WIDTH-5)) THEN SETLENGTH(LINE[I],(WIDTH-5)) ELSE
  94.     FOR COUNTER:= LENGTH(LINE[I]) TO (WIDTH-5) DO APPEND(LINE[I],' ');
  95.     
  96. {don't allow lines wider than WIDTH-5 since these wouldn't fit neatly on label}
  97. {and, if the line is < WIDTH-5 characters, pad it so it will appear centered}
  98.  
  99. writeln('Prepare printer, by positioning printer head  approximately ');
  100. writeln('five spaces from left edge and at very top of the 1st label');
  101. writeln('and then enter a carriage return. ');
  102. READLN(CONTINUE);
  103.  
  104.  
  105. FOR I:= 1 TO NUMBER DO  
  106.     BEGIN
  107.         FOR COUNTER:= 1 TO TOP_MARGIN DO WRITELN(FOUT);
  108.  
  109.         FOR COUNTER:= 1 TO 4 DO
  110.     IF SPACING = 1 THEN WRITELN(FOUT,LINE[COUNTER]) 
  111.                 ELSE
  112.     WRITELN(FOUT,LINE[COUNTER],SPACE,LINE[COUNTER],SPACE,LINE[COUNTER]);
  113.  
  114.     FOR COUNTER:= 1 TO (BOTTOM_MARGIN + GAP) DO WRITELN(FOUT);
  115.     {allow for vertical distance between labels on form feed sheet...}
  116.         
  117.     END;
  118.  
  119. END.