home *** CD-ROM | disk | FTP | other *** search
/ World of Shareware - Software Farm 2 / wosw_2.zip / wosw_2 / CPROG / C-BAR1.ZIP / PRBAR.TSH < prev    next >
Text File  |  1992-02-27  |  1KB  |  75 lines

  1. /*
  2.  * prbar - print a thick or thin line or space
  3.  * TOSH/QUME version (P321)
  4.  * written 1987 David J. Rodman
  5.  * Paradise Technology, Inc.
  6.  */
  7.  
  8. #include <stdio.h>
  9. extern int res, depth;     /* settings for width and heigth of barcode */
  10. static char *str;    /* the string to encode */
  11. extern char *text[];       /* text for the right-hand part of label */
  12. extern lineno;        /* current line of label */
  13.  
  14.  
  15. /*
  16.  * initialize the printer as required to print string s
  17.  */
  18. prinit(s)
  19.     char *s;
  20. {
  21.     char *asclen();        /* convert string length to ascii chars */
  22.     int n;
  23.  
  24.     str = s;    
  25.     n = 16 * res * (strlen(s) + 2);        /* total # of graphic bytes */
  26.     printf("%c%c%c", 0x1b, 0x1e, 7);    /* 8 lpi */
  27.     printf("%c>", 0x1b);            /* no bidirectional print */
  28.     printf("%c;%s", 0x1b, asclen(n));    /* enter graphics mode */
  29. }
  30.  
  31. /*
  32.  * print bottom line defined as text[0]
  33.  */
  34. prfini()
  35. {
  36.     int i;
  37.  
  38.     printf("\n%s\n", text[0]);
  39. }
  40.  
  41. static char *asclen(n)
  42. {
  43.     static char buf[5];
  44.     char *p;
  45.  
  46.     sprintf(buf, "%4d", n);
  47.     for(p = &buf[0]; *p == ' '; p++)
  48.         *p = '0';
  49.     return &buf[0];
  50. }
  51.  
  52. /*
  53.  * print an individual line or space, thick or thin 
  54.  * args are boolean
  55.  */
  56. prbar(thick, line)
  57. {
  58.     int w, c;
  59.  
  60.     w = res * (thick ? 3 : 1);
  61.     c = line ? 0xff : 0;
  62.     while(w--)
  63.         printf("%c%c%c%c", c, c, c, c);
  64. }
  65.  
  66. /*
  67.  * move down one line, printing the appropriate text
  68.  */
  69. prdown()
  70. {
  71.      printf(" %s", text[lineno++]);
  72.     printf("%c%c", 0x0d, 0x0a);
  73. }
  74.  
  75.