home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD2.mdf / c / library / dos / window / ultrawin / uw_help6.hlp < prev    next >
Encoding:
Text File  |  1992-01-20  |  15.7 KB  |  402 lines

  1. `co(4,7);──────────────────────────── /// Print Support ───────────────────────────────`co();
  2.  
  3.                                `keyword(Introduction,/// Introduction);
  4.                            `keyword(Key Structure Elements,/// Key Structure Elements);
  5.  
  6.  ┌──────────────────────────────────────────────────────────────────────────┐    
  7.  │               `keyword(init_printer,/// init_printer);                `keyword(end_printer,/// end_printer);                    │
  8.  │               `keyword(print_char,/// print_char);                  `keyword(print_data,/// print_data);                     │
  9.  │               `keyword(print_eol,/// print_eol);                   `keyword(print_file,/// print_file);                     │
  10.  │               `keyword(print_screen,/// print_screen);                `keyword(print_str,/// print_str);                      │
  11.  │               `keyword(print_window,/// print_window);                `keyword(realloc_printer,/// realloc_printer);                │
  12.  │               `keyword(set_prt_xlat,/// set_prt_xlat);                `keyword(print_in_bkgrnd,/// print_in_bkgrnd);                │
  13.  └──────────────────────────────────────────────────────────────────────────┘
  14.  
  15. `color(RED,LIGHTGRAY);─────────────────────────── /// Introduction ─────────────────────────────────`color();
  16.  
  17.       These routines are primarily designed for printing to a printer.
  18.     However, printing can be output to a DOS file or device (com1, lpt1,
  19.     tmp.dat, etc).  UltraWin can have as many as four print queues active and
  20.     printing concurrently!  The queuing routines are unique in the fact that
  21.     the can "dynamically" reallocate themselves and "grow" and "shrink" on the
  22.     fly without losing a single byte of data.  The reallocation routines take
  23.     advantage of the lightning fast movmem, as much out of convenience as
  24.     speed.  An 8Mhz 286 can que 25,000 bytes worth of text strings in one
  25.     second, reallocating every 2048 bytes; really quite remarkable.  The
  26.     output is very fast.  Under normal operation, a "write" occurs on every
  27.     byte, resulting in ~1024 bytes per second (on the same machine).  Not many
  28.     printers can keep up with this speed!  Even greater speed is achieved by
  29.     using "block mode", where each write can output 512 bytes at a time.  This
  30.     is not done by default since outputting to a comm port at a slow baud rate
  31.     could hamper overall performance.
  32.  
  33. `color(RED,LIGHTGRAY);─────────────────────── /// Key Structure Elements ───────────────────────────`color();
  34.  
  35.       Several print structure elements are of importance.  These elements can
  36.     be modified directly for the desired effect.
  37.      
  38.     The `co(15,1);halt`co(); member controls output from the queue.  If 1, output stops
  39.   and the data in the queue remains unmodified.  If set to 0, output
  40.   continues.
  41.  
  42.     The `co(15,1);block_mode`co(); member controls the number of bytes output per
  43.   call to the function "print_in_bkgnd".  If 0, only one byte per call will
  44.     be output.  This is useful for communication devices or printers.  If
  45.     outputting to a file or laser printer, setting block mode to 1 will allow
  46.     up to 512 bytes to be output per call, thereby increasing performance.
  47.     This value is defined in UW.H.  Changing this value and recompiling
  48.     UW_PRINT.C will allow you to change the number of bytes send per block.
  49.  
  50.         The `co(15,1);xlat`co(); and `co(15,1);xlat_flag`co(); control printer translation.  See `keyword(set_prt_xlat,/// set_prt_xlat);
  51.     for more details.
  52.  
  53. `co(10,1);/// init_printer`co();   `keyword(source,[UW_PRINT.C]~init_printer);
  54.       Initializes a printer queue.  Printer queues can be either ram-based or
  55.     disk-based. If ram-based, a queue can be no greater than 64k.  Disk-based
  56.     queues can be up to 2 gigabytes. (Though we have never actually tried this
  57.     size!).  If disk-based, the initial and maximum size should be set to the
  58.     same value, and a second filename is used as a disk buffer.  Be sure that
  59.     the isize and msize values are "long". If any error occurs (file cannot be
  60.     open, memory cannot be allocated,etc) a 0 will be returned.
  61.  
  62. Prototype:
  63.     int init_printer( char *fname, char *diskbuff, long isize,
  64.                                         long msize, PRINT *p );
  65.  
  66. Parameters:
  67. `co(11,1);    char  *fname`co();
  68.         A pointer to a string containing the filename/device to print to.
  69. `co(11,1);    char  *diskbuff`co();
  70.         A pointer to a string containing the filename/device to use as a disk
  71.     buffer.  This is NULL for ram-based queues.
  72. `co(11,1);    long  isize`co();
  73.         The initial size of the print queue. (Maximum 64k if ram based)
  74. `co(11,1);    long  msize`co();
  75.         The maximum size of the print queue. (Maximum 64k if ram based)
  76.         isize and msize should be set equal if using a disk based queue.
  77. `co(11,1);    PRINT *p`co();
  78.     A pointer to a print queue structure.   
  79.  
  80. Usage:
  81.     PRINT printer1, printer2;
  82.     ...
  83.     if( !init_printer("out1.prt", NULL, 2048L, 16384L, &printer1) )
  84.         wn_plst(0,0,"cannot initialize printer", wnp);
  85.     if( !init_printer("out2.prt", "disk.buf", 32768L, 32768L, &printer2) )
  86.         wn_plst(0,0,"cannot initialize printer", wnp);
  87.  
  88. `co(10,1);/// end_printer`co();   `keyword(source,[UW_PRINT.C]~end_printer);
  89.       Closes any files and frees any memory used by the print queue.  If
  90.     disk-based, the temporary disk file is left intact so that it will not
  91.     have to be recreated during the next program execution. You may delete
  92.     this file yourself if desired.
  93.  
  94. Prototype:
  95.     int end_printer( PRINT *p );
  96.  
  97. Parameters:
  98. `co(11,1);    PRINT *p`co();
  99.     A pointer to a print queue structure.   
  100.  
  101. Usage:
  102.     PRINT printer1;
  103.     ...
  104.     end_printer(&printer1);
  105.  
  106. `co(10,1);/// print_char`co();   `keyword(source,[UW_PRINT.C]~print_char);
  107.       Prints a single character.     A 0 is returned if an error occurs.
  108.  
  109. Prototype:
  110.     int print_char( uchar c, PRINT *p );
  111.  
  112. Parameters:
  113. `co(11,1);    uchar c`co();
  114.     A single byte to queue for printing.   
  115. `co(11,1);    PRINT *p`co();
  116.     A pointer to a print queue structure.   
  117.  
  118. Usage:
  119.     PRINT printer1;
  120.     ...
  121.     print_char('\r', &printer1);
  122.  
  123. `co(10,1);/// print_data`co();   `keyword(source,[UW_PRINT.C]~print_data);
  124.       Prints a block of data.  A 0 is returned if an error occurs.
  125.  
  126. Prototype:
  127.     int print_data( uchar *data, int cnt, PRINT *p );
  128.  
  129. Parameters:
  130. `co(11,1);    uchar *data`co();
  131.     A pointer to the data to queue for printing.   
  132. `co(11,1);    int   cnt`co();
  133.     The number of bytes to print.   
  134. `co(11,1);    PRINT *p`co();
  135.     A pointer to a print queue structure.   
  136.  
  137. Usage:
  138.     uchar data[132];
  139.     PRINT printer1;
  140.     ...
  141.     print_data(data, 132, &printer1);
  142.  
  143. `co(10,1);/// print_eol`co();   `keyword(source,[UW_PRINT.C]~print_eol);
  144.       Prints an end-of-line sequence.  The print structure contains two
  145.     variables, "cr_cnt" and "lf_cnt" that control this sequence.  For every
  146.     carriage return "cr_cnt", "lf_cnt" line feeds are printed.
  147.     
  148.         For instance, the simple case of cr_cnt = lf_cnt = 1 outputs \r\n  while
  149.     cr_cnt = 1, lf_cnt = 2 outputs \r\n\n.  A 0 is returned if an error
  150.     occurs.
  151.  
  152. Prototype:
  153.     int print_eol( PRINT *p );
  154.  
  155. Parameters:
  156. `co(11,1);    PRINT *p`co();
  157.     A pointer to a print queue structure.   
  158.  
  159. Usage:
  160.     PRINT printer1;
  161.     ...
  162.     print_eol(&printer1);
  163.  
  164. `co(10,1);/// print_file`co();   `keyword(source,[UW_PRINT.C]~print_file);
  165.       Prints an entire file.  The file is queued in "raw" format, no CR/LF
  166.     translation occurs.  Make sure that there is enough room in the queue to
  167.     hold the entire file.  A 0 is returned if an error occurs.
  168.  
  169. Prototype:
  170.     int print_file( char *fname, PRINT *p );
  171.  
  172. Parameters:
  173. `co(11,1);    char  *fname`co();
  174.         A pointer to a string containing the filename/device to print to.
  175. `co(11,1);    PRINT *p`co();
  176.     A pointer to a print queue structure.   
  177.  
  178. Usage:
  179.     PRINT printer1;
  180.     ...
  181.     print_file("uw_help6.hlp", &printer1);
  182.  
  183. `co(10,1);/// print_screen`co();   `keyword(source,[UW_PRINT.C]~print_screen);
  184.       Prints the contents of the entire screen.  A 0 is returned if an error
  185.     occurs.
  186.  
  187. Prototype:
  188.     int print_screen( PRINT *p );
  189.  
  190. Parameters:
  191. `co(11,1);    PRINT *p`co();
  192.     A pointer to a print queue structure.   
  193.  
  194. Usage:
  195.     PRINT printer1;
  196.     ...
  197.     print_screen(&printer1);
  198.  
  199. `co(10,1);/// print_str`co();   `keyword(source,[UW_PRINT.C]~print_str);
  200.       Prints a single NULL terminated string.  A 0 is returned if an error
  201.     occurs.
  202.  
  203. Prototype:
  204.     int print_str( uchar *str, PRINT *p );
  205.  
  206. Parameters:
  207. `co(11,1);    char  *str`co();
  208.         A pointer to the string to print.
  209. `co(11,1);    PRINT *p`co();
  210.     A pointer to a print queue structure.   
  211.  
  212. Usage:
  213.     PRINT printer1;
  214.     ...
  215.     print_string("This is a print string", &printer1);
  216.  
  217. `co(10,1);/// print_window`co();   `keyword(source,[UW_PRINT.C]~print_window);
  218.       Prints the contents of the current window.  If the window is bordered
  219.     and the window parameter "inside" is 1, only the inside of the window is
  220.     printed.  If "inside" is 0, the entire window, including the border is
  221.     printed.  A 0 is returned if an error occurs.  Note that this works even
  222.     if the window is overlapped!
  223.  
  224. Prototype:
  225.     int print_window( WINDOW *wnp, PRINT *p );
  226.  
  227. Parameters:
  228. `co(11,1);    WINDOW *wnp`co();
  229.         A pointer to the window to print.
  230. `co(11,1);    PRINT  *p`co();
  231.     A pointer to a print queue structure.   
  232.  
  233. Usage:
  234.     PRINT printer1;
  235.     WINDOW wn;
  236.     ...
  237.     print_window(&wn, &printer1);
  238.  
  239. `co(10,1);/// realloc_printer`co();   `keyword(source,[UW_PRINT.C]~realloc_printer);
  240.       Is used internally to "grow" and "shrink" ram-based printer queues
  241.     dynamically.  A 0 is returned if an error occurs.
  242.  
  243. Prototype:
  244.     int realloc_printer( long new_size, PRINT *p );
  245.  
  246. Parameters:
  247. `co(11,1);    long new_size`co();
  248.         The new size, either greater or less than the current size.
  249. `co(11,1);    PRINT  *p`co();
  250.     A pointer to a print queue structure.   
  251.  
  252. Usage:
  253.     PRINT printer1;
  254.     ...
  255.     realloc_printer(32000L, &printer1);
  256.  
  257. `co(10,1);/// set_prt_xlat`co();   `keyword(source,[UW_PRINT.C]~set_prt_xlat);
  258.       Allows translation of the data through a 256-byte translation table.
  259.     For instance, the ASCII data queued can be printed as EBCDIC by pointing
  260.     this to the appropriate table.  Another example would be to point to a
  261.     table that contained ASCII equivalents to the IBM extended characters,
  262.     thereby providing support for older printers that do not support them.
  263.     Note that the translation occurs during output, not during the queueing
  264.     process.
  265.  
  266. Prototype:
  267.     void set_prt_xlat( int state, uchar *xlat, PRINT *p );
  268.  
  269. Parameters:
  270. `co(11,1);    int   state`co();
  271.         If 1, the translation table is activated, if 0 it is deactivated.
  272. `co(11,1);    uchar *xlat`co();
  273.         A pointer to the translation table.
  274. `co(11,1);    PRINT  *p`co();
  275.     A pointer to a print queue structure.   
  276.  
  277. Usage:
  278.     uchar xlat[256];
  279.     PRINT printer1;
  280.     ...
  281.     set_prt_xlat(1, xlat, &printer1);
  282.  
  283. `co(10,1);/// print_in_bkgrnd`co();   `keyword(source,[UW_PRINT.C]~print_in_bkgrnd);
  284.       Is the "heart" of the printer routines.  It actually scans the printer
  285.     queues and outputs the data to the appropriate file/device. You can call
  286.     this routine as often and as fast as you see fit, or let the idle function
  287.     call it in the "background".  There are no requirements as to when or how
  288.     often this routine is called, but the more frequent the better the printer
  289.     performance.  The total number of bytes output is returned.
  290.  
  291. Prototype:
  292.     int print_in_bkgrnd( void );
  293.  
  294. Parameters:
  295.  
  296. Usage:
  297.     ...
  298.     while( !kbhit() )
  299.         print_in_bkgrnd();
  300. OR
  301.     set_idle_func(print_in_bkgrnd);        /* wait event will call this for us */
  302.     do{
  303.             ...
  304.   }while(!end);
  305.  
  306. `co(4,7);───────────────────────── /// Timer/Sound Support ────────────────────────────`co();
  307.  
  308.       UltraWin V2.0 has the additional capability of "taking over" the PC
  309.     timer interrupt.  It does this in a friendly manner by calling the old
  310.     timer vector at the proper rate.  UltraWin increases the timer interrupt
  311.     rate by a factor of 5, or approximately 91 ticks per second.  This allows
  312.     you much finer control over your programs.  We also provide you with an
  313.     easy to use timer facility for taking advantage of these features.
  314.     UltraWin also allows you to sound the PC speaker at a given frequency for
  315.     a certain amount of time and the timer interrupt will turn the speaker off
  316.     for you.
  317.  
  318.         It is very important to remember to call end_clock before exiting
  319.     your program.  If you do not, you may experience strange crashes.
  320.   The function `co(11,1);end_video()`co(); calls `co(11,1);end_clock()`co(); to restore the vector and
  321.   clock rate if you forget to make the call.  Taking over the PC timer will
  322.   not affect the PC clock as the original interrupt is still called 18.2
  323.   times per second.  However, if your program or another program that 
  324.   controls your program also takes over the clock and changes the rate you
  325.   may experience some problems.  If this is the case, simply do not call
  326.   `co(11,1);init_clock()`co();.  You will not be able to use the timer variables or
  327.   call `co(11,1);tone()`co(); but `co(11,1);wait_ticks()`co(); will still operate normally.
  328.   
  329.   There are 4 seperate countdown timers available for use in your programs.
  330.   These are simply global variables that are decremented to 0 by the timer
  331.   interrupt.  For instance, to set a countdown timer that will reach 0
  332.   after 1 second, say `co(11,1);Uw_timers[0] = 91;`co(); You can then poll this
  333.   variable at your convenience to determine the time expired.  The
  334.   interrupt decrements the variable by 1 on each tick until the count
  335.   reaches 0, at which time it will remain 0.  The global variables
  336.   `co(11,1);Sys_timers`co(); and `co(11,1);Sound_timer`co(); should not be accessed as these are
  337.   used by UltraWin and it's companion product InTUItion.
  338.   
  339. `co(10,1);/// init_clock`co();   `keyword(source,[UW_VID.C]~init_clock);
  340.       Takes over the PC timer interrupt and sets the timer rate to the desired
  341.     value.                                              
  342.  
  343. Prototype:
  344.     void init_clock( int value );
  345.  
  346. Parameters:
  347. `co(11,1);    uint  value`co();
  348.     The countdown value for the PC timer chip.  0xffff is the standard
  349.     18.2 times per second. 0x7fff would increase the rate by 2, etc.
  350.     
  351. Usage:
  352.     ...
  353.      init_clock(0x3333);                                            /* speed up by factor of 5 */
  354.  
  355. `co(10,1);/// end_clock`co();   `keyword(source,[UW_VID.C]~end_clock);
  356.       Restores the timer interrupt and rate.  Be sure to call this function
  357.     before exiting your program.  `co(11,1);end_video()`co(); will call this for
  358.     you if you forget.
  359.  
  360. Prototype:
  361. void end_clock();
  362.  
  363. Parameters:
  364.  
  365. Usage:
  366.     ...
  367.      end_clock();
  368.     end_mouse();
  369.     end_video();
  370.     exit(0);
  371.   
  372. `co(10,1);/// tone`co();   `keyword(source,[UW_VID.C]~tone);
  373.       Sounds the PC speaker at the desired frequency for the desired amount of
  374.     time measured in timer tics. (91/s).  There is no need to turn the sound
  375.     off, this is automatically handled by the timer interrupt.  It is
  376.     perfectly safe to call tone even if a tone is already in progress.  The
  377.     new frequency and time will override the current values.  If you need to
  378.     turn the speaker off before the time has expired you can call `co(11,1);sound_off();`co();
  379.  
  380. Prototype:
  381. void tone( uint freq, int dur );
  382.  
  383. Parameters:
  384. `co(11,1);    uint  freq`co();
  385.     The desired frequency in hertz or cycles-per-second.   
  386. `co(11,1);    int    dur`co();
  387.     The duration of the tone in clock tics (91-per-second).
  388.  
  389. Usage:
  390.     ...
  391.   if( error )
  392.       tone(1024,9);                                                    /* sound at 1k for 1/10 second */
  393.  
  394. `co(4,7);──────────────────────── /// Ctrl-C/Ctrl-Break Control ───────────────────────`co();
  395.   
  396.       UltraWin takes over the Ctrl-C and Ctrl-Break handlers and installs
  397.     a dummy interrupt handler.  In this way, Ctrl-C can be used as any other
  398.     control key.  More importantly, your program will not abort without
  399.     restoring the clock interrupt.  If you need further control over these
  400.     handlers you can modify the ISR's `co(11,1);uw_ctrl_brk();`co(); and `co(11,1);uw_ctrl_c()`co();.
  401.   
  402.