home *** CD-ROM | disk | FTP | other *** search
/ Sound Sensations! / sound_sensations.iso / cmf / laser / demo.prg next >
Encoding:
Text File  |  1989-12-03  |  7.5 KB  |  295 lines

  1. **************************************
  2. * demo.prg  (Clipper specific)
  3. *  Demo of HP LaserJet Routines to draw lines and boxes.
  4. *
  5. *  Written 12/89 by 
  6. *        Kevin Talbot
  7. *        KJT enterprises
  8. *        7632 SE 37th Place
  9. *        Mercer Island, WA 98040
  10. *        (206) 236-1060
  11. *        Compuserve ID: 75706,316 
  12. * This program is "public domain" and is free for anyone to use or modify.
  13. * Acknowledgement of the author would be appreciated.
  14.  
  15.  
  16. * Notes: Requires to module LASER.PRG for proper functioning.
  17. *        Assumes 'set print on' will connect with your LaserJet.
  18.  
  19. save screen to foo
  20. clear
  21. store 0.0 to r,c,x,y,l,h,w,t,func
  22. store "   " to f
  23. store " " to o
  24. set confirm on
  25. set print on
  26. set device to screen
  27. set console off
  28. set wrap on
  29. msg = 17
  30. status = 23
  31.  
  32. do laser     && drag in the functions automatically during compile
  33.  
  34.  
  35. do while func != 7
  36.  
  37.   set device to screen
  38.   clear
  39.   func = 1
  40.   set message to msg center
  41.   @ 3,27 say "LaserJet Function Demonstration"
  42.   @ 2,10 to 15,69 double
  43.   @ 4,11 to 4,68  
  44.   @  6,27 prompt " Lines                 " ;
  45.           message "Draws horizontal and vertical lines"
  46.  
  47.   @  7,27 prompt " Filled rectangles     " ;
  48.           message "Draws pattern-filled rectangles"
  49.  
  50.   @  8,27 prompt " Text Position (@ r,c) " ;
  51.           message "For correlating text via 'lj_say() and graphics 'x,y' positions"
  52.  
  53.   @  9,27 prompt " Boxes                 " ;
  54.           message "Draws ruled boxes (not filled in, just the borders)"
  55.  
  56.   @ 10,27 prompt ' Add .25" Grid & Print ' ;
  57.           message 'Adds a 1/4" grid for reference and then prints the page'
  58.  
  59.   @ 11,27 prompt ' Add .10" Grid & Print ' ;
  60.           message 'Adds a 1/10" grid for reference and then prints the page'
  61.  
  62.   @ 12,27 prompt " Print Page w/o Grid   " ;
  63.           message "Prints the page as is w/o reference grid"
  64.  
  65.   @ 13,27 prompt " Quit WITHOUT Printing " ;
  66.           message "Return to DOS WITHOUT printing the page"
  67.  
  68.   menu to func
  69.  
  70.   do case
  71.  
  72.     case func = 1     && draw lines
  73.       do while lastkey() <> 27
  74.          clear
  75.          @  2,10 say " Draw Line in INCHES ([Esc] to Quit)"
  76.          @  4,10 say "           Start at x:" get x picture "9999.999"
  77.          @  6,10 say "                    y:" get y picture "9999.999"
  78.          @  8,10 say "               Length:" get l picture "9999.999"
  79.          @ 10,10 say "            Thickness:" get t picture "9999.999"
  80.          @ 12,10 say "    Orientation (H/V):" get o picture "!"
  81.          @ 14,10 say "  % Gray or Pattern #:" get f
  82.          read
  83.          if lastkey() != 27
  84.            @ status,26 say "Sending Data To Printer..."
  85.            lj_gotoxy(x,y)
  86.            lj_line(l,t,o,f)
  87.            @ status,0
  88.          endif
  89.       enddo
  90.  
  91.     case func = 2      && filled rectangles
  92.       do while lastkey() <> 27
  93.          clear
  94.          @  2,10 say " Filled Rectangles in INCHES ([Esc] to Quit)"
  95.          @  4,10 say "    Upper left at x:" get x picture "9999.999"
  96.          @  6,10 say "                  y:" get y picture "9999.999"
  97.          @  8,10 say "              Width:" get w picture "9999.999"
  98.          @ 10,10 say "             Height:" get h picture "9999.999"
  99.          @ 12,10 say "% Gray or Pattern #:" get f 
  100.          read
  101.          if lastkey() != 27
  102.            @ status,26 say "Sending Data To Printer..."
  103.            lj_gotoxy(x,y)
  104.            lj_fill(w,h,f)
  105.            @ status,0
  106.          endif
  107.       enddo
  108.  
  109.     case func = 3    && position text and print grid
  110.       setprc(0,0)
  111.       do while lastkey() <> 27
  112.          set device to screen
  113.          clear
  114.          @  2,10 say " Text Position via 'lj_say()' ([Esc] to Quit)"
  115.          @  4,10 say "      Row:" get r picture "99" range 0,59
  116.          @  6,10 say "      Col:" get c picture "99" range 0,80
  117.          @ 10,10 say "(The character '█' will be printed at r,c)"
  118.          read
  119.          if lastkey() != 27
  120.            @ status,26 say "Sending Data To Printer..."
  121.            set device to print
  122.            string = alltrim(str(r,2)) + "," + alltrim(str(c,2))
  123.            if (c + len(string) +1) > 78
  124.              lj_say(r,c-len(string), string + '█')
  125.            else
  126.              lj_say(r,c,"█" + string)
  127.            endif
  128.            @ status,0
  129.          endif
  130.       enddo
  131.  
  132.  
  133.      case func = 4  && draw boxes
  134.        do while lastkey() <> 27 
  135.          clear
  136.          @  2,10 say " Draw a box in INCHES ([Esc] to Quit)"
  137.          @  4,10 say "    Upper left at x:" get x picture "9999.999"
  138.          @  6,10 say "                  y:" get y picture "9999.999"
  139.          @  8,10 say "              Width:" get w picture "9999.999"
  140.          @ 10,10 say "             Height:" get h picture "9999.999"
  141.          @ 12,10 say "          Thickness:" get t picture "9999.999"
  142.          @ 14,10 say "% Gray or Pattern #:" get f
  143.          read
  144.          if lastkey() != 27
  145.            @ status,26 say "Sending Data To Printer..."
  146.            lj_gotoxy(x,y)
  147.            lj_box(w,h,t,f)
  148.            @ status,0
  149.          endif
  150.        enddo
  151.  
  152.  
  153.      case func = 5  && print page w/ 1/4" grid 
  154.        @ status,26 say "Sending Data To Printer..."
  155.        do grid4
  156.        @ status,0
  157.        eject
  158.  
  159.  
  160.      case func = 6  && print page w/ 1/10" grid 
  161.        @ status,26 say "Sending Data To Printer..."
  162.        do grid10
  163.        @ status,0
  164.        eject
  165.  
  166.  
  167.      case func = 7  && print page w/o grid
  168.        eject       
  169.  
  170.  
  171.      case func = 8  && quit 
  172.        restore screen from foo
  173.        quit
  174.  
  175.    endcase
  176.  
  177. enddo
  178.  
  179. restore screen from foo
  180.  
  181. return
  182.  
  183.  
  184.  
  185. procedure grid4
  186.  
  187.   private i, wide, nar, one_dot
  188.   one_dot = 0.0033333333
  189.   wide= 5 * one_dot
  190.   med = 3 * one_dot
  191.   nar = 1 * one_dot
  192.  
  193.   * draw horizontal 1" lines
  194.   for i = 0.0 to 10.0
  195.     lj_gotoxy(0.0,i)
  196.     lj_line(9.0,wide,"H","100")
  197.   next
  198.  
  199.   * draw vertical 1" lines
  200.   for i = 0.0 to 8.0
  201.     lj_gotoxy(i,0.0)
  202.     lj_line(11.0,wide,"V","100")
  203.   next
  204.   * fake in the line @ 8"
  205.   lj_gotoxy(7.987,0.0)
  206.   lj_line(11.0,wide,"V","100")
  207.  
  208.   * draw horizontal 1/2" lines
  209.   for i = 0.5 to 10.0 
  210.     lj_gotoxy(0.0,i)
  211.     lj_line(9.0,med,"H","100")
  212.   next
  213.  
  214.   * draw vertical 1/2" lines
  215.   for i = 0.5 to 8.0 
  216.     lj_gotoxy(i,0.0)
  217.     lj_line(11.0,med,"V","100")
  218.   next
  219.  
  220.   * draw horizontal 1/4" lines
  221.   for i = 0.25 to 10.25 step 0.5
  222.     lj_gotoxy(0.0,i)
  223.     lj_line(9.0,nar,"H","100")
  224.   next
  225.  
  226.   * draw vertical 1/4" lines
  227.   for i = 0.25 to 8.0 step 0.5
  228.     lj_gotoxy(i,0.0)
  229.     lj_line(11.0,nar,"V","100")
  230.   next
  231.  
  232.  
  233. return
  234.  
  235.  
  236.  
  237. procedure grid10
  238.  
  239.   * draws a 1/10" grid on the page
  240.  
  241.   private i, wide, nar, one_dot
  242.   one_dot = 0.0033333333
  243.   wide= 5 * one_dot
  244.   med = 3 * one_dot
  245.   nar = 1 * one_dot
  246.  
  247.   * draw horizontal 1" lines
  248.   for i = 0.0 to 10.0
  249.     lj_gotoxy(0.0,i)
  250.     ?? ltrim(str(i,4))
  251.     lj_gotoxy(0.0,i)
  252.     lj_line(9.0,wide,"H","100")
  253.   next
  254.  
  255.   * draw vertical 1" lines
  256.   for i = 0.0 to 8.0
  257.     lj_gotoxy(i,0.0)
  258.     ?? ltrim(str(i,4))
  259.     lj_gotoxy(i,0.0)
  260.     lj_line(11.0,wide,"V","100")
  261.   next
  262.   * fake in the line @ 8"
  263.   lj_gotoxy(7.987,0.0)
  264.   lj_line(11.0,wide,"V","100")
  265.  
  266.   * draw horizontal 1/2" lines
  267.   for i = 0.5 to 10.0 
  268.     lj_gotoxy(0.0,i)
  269.     lj_line(9.0,med,"H","100")
  270.   next
  271.  
  272.   * draw vertical 1/2" lines
  273.   for i = 0.5 to 8.0 
  274.     lj_gotoxy(i,0.0)
  275.     lj_line(11.0,med,"V","100")
  276.   next
  277.  
  278.   * draw horizontal 1/10" lines
  279.   for i = 0.1 to 10.3 step 0.1
  280.     lj_gotoxy(0.0,i)
  281.     lj_line(9.0,nar,"H","100")
  282.   next
  283.  
  284.   * draw vertical 1/10" lines
  285.   for i = 0.1 to 8.0 step 0.1
  286.     lj_gotoxy(i,0.0)
  287.     lj_line(11.0,nar,"V","100")
  288.   next
  289.  
  290.  
  291. return
  292.  
  293.