home *** CD-ROM | disk | FTP | other *** search
/ Microsoft Programmer's Library 1.3 / Microsoft-Programers-Library-v1.3.iso / sampcode / alde_c / turbo_c / tcxl / tcxl.doc next >
Encoding:
Text File  |  1988-12-22  |  121.0 KB  |  3,660 lines

  1.                                     T C X L
  2.                     An Extended Function Library for Turbo C
  3.                                   Version 3.3
  4.                                  by Mike Smedley
  5.                        (c) 1987, 1988  All Rights Reserved
  6.  
  7.     This library is intended to be a supplement to the Turbo C function
  8. library.  It contains over 170 functions designed for use with the tiny and
  9. small memory models.  Libraries for the other models are provided with
  10. registration.  This library was compiled with Turbo C 1.5, however, you do not
  11. need TC 1.5 to use this library.  The following files should be included in
  12. this:
  13.  
  14.                 TCXL.DOC      - the library documentation
  15.                 TCXL.H        - header file for all functions
  16.                 TCXL.LIB      - the object code library
  17.                 TCXLDEF.H     - header file for miscellaneous functions
  18.                 TCXLDEMO.C    - the demonstration program source code
  19.                 TCXLDEMO.MAK  - the make file used for compiling the demo
  20.                 TCXLDEMO.PRJ  - project file used for compiling the demo
  21.                 TCXLDSK.H     - header file for disk functions
  22.                 TCXLEMS.H     - header file for EMS functions
  23.                 TCXLHIST.DOC  - history of changes
  24.                 TCXLKEY.H     - header file for keyboard functions
  25.                 TCXLMOU.H     - header file for mouse functions
  26.                 TCXLPRN.H     - header file for printer functions
  27.                 TCXLQREF.DOC  - quick reference for TCXL functions
  28.                 TCXLSTR.H     - header file for string functions
  29.                 TCXLVID.H     - header file for video functions
  30.                 TCXLWIN.H     - header file for windowing functions
  31.  
  32.  
  33. Features of the TCXL Function Library.
  34.  
  35.             -   Windowing with multiple windows
  36.             -   Lotus/Intel/Microsoft EMS memory usage
  37.             -   EGA 43-line and VGA 50-line modes
  38.             -   Mouse functions for Microsoft compatible mice
  39.             -   Direct screen writing for fast screen writes
  40.             -   Screen/window swapping to memory or disk
  41.             -   DESQview window compatibility
  42.             -   Advanced string manipulation
  43.             -   String Pattern matching
  44.             -   Data encryption
  45.             -   Multi-field keyboard input from within windows
  46.             -   Bar-selection/pull-down menus
  47.             -   Formatted keyboard input
  48.             -   Equipment detection
  49.             -   Printing functions
  50.             -   Sound function
  51.             -   and more!
  52.  
  53.  
  54.  
  55.  
  56.  
  57.  
  58.  
  59.                                       1    
  60.  
  61.  
  62.  
  63. Registration Information.
  64.  
  65.     You are free to copy and distribute this library freely, however, if you
  66. find this library of use to you, you are encouraged to register your copy.  The
  67. registration cost is $20.  Included in this registration cost is technical
  68. support; libraries for the Medium, Compact, Large, and Huge memory models;
  69. low-cost upgrades to future revisions; and best of all, the complete library
  70. source code!  This library may not be used in commercial applications without
  71. registration.  To register, please send payment and current version number to:
  72.  
  73.                     Mike Smedley
  74.                     2441 N.E. Loop 410 #1505
  75.                     San Antonio, TX 78217
  76.  
  77.     Or, for more information, I can be reached at one of the following points
  78. of contact:
  79.  
  80.         Telephone       -   (512) 590-2910  (no collect calls, please)
  81.         CompuServe      -   User ID:  71331,2244
  82.         GEnie           -   Mail address:  M.SMEDLEY
  83.         Abbey Road BBS  -   (512) 590-6036  1200/2400/9600 8-N-1
  84.         Telstar BBS     -   (512) 822-8882  1200/2400 8-N-1
  85.  
  86.  
  87.  
  88. DISCLAIMER:  The author claims no responsibility for any damages caused by the
  89. use or misuse of this library.  This product is distributed "as is" with no
  90. warranty expressed or implied.
  91.  
  92.  
  93. Trademarks Used:
  94.  
  95.     CompuServe is a registered trademark of CompuServe Incorporated.
  96.     DESQview is a trademark of Quarterdeck Office Systems.
  97.     Epson is a registered trademark of Seiko Epson Corporation.
  98.     IBM is a registered trademark of International Business Machines.
  99.     LIM and EMS are trademarks of Lotus, Intel, and Microsoft Corporations.
  100.     Microsoft is a registered trademark of Microsoft Corporation.
  101.     Turbo C is a registered trademark of Borland International.
  102.  
  103.  
  104.  
  105.  
  106.  
  107.  
  108.  
  109.  
  110.  
  111.  
  112.  
  113.  
  114.  
  115.  
  116.  
  117.  
  118.  
  119.                                       2    
  120.  
  121.  
  122.  
  123.  
  124.  
  125. Calling TCXL Functions from Turbo C.
  126.  
  127.  
  128.     To call these functions from Turbo C, you will need to have a line in your
  129. source code file including the appropriate TCXL header file.  Example:
  130.  
  131.         #include "tcxlwin.h"
  132.  
  133.     You will also need to link in the TCXL.LIB file when you link your program.
  134. You can do this in one of three ways:
  135.  
  136.         1.  Compile & link from the environment.  Your project (.PRJ) file
  137.             must contain 'TCXL.LIB' in it.  It should look like:
  138.  
  139.                 myfile tcxl.lib
  140.  
  141.         2.  Compile & link from the command line.  Type:
  142.  
  143.                 tcc myfile tcxl.lib
  144.  
  145.         3.  Command line link only.  Type:
  146.  
  147.                 tlink c0s myfile,myfile,,tcxl emu maths cs /c/x
  148.  
  149.  
  150.  
  151.  
  152.  
  153.  
  154.  
  155.  
  156.  
  157.  
  158.  
  159.  
  160.  
  161.  
  162.  
  163.  
  164.  
  165.  
  166.  
  167.  
  168.  
  169.  
  170.  
  171.  
  172.  
  173.  
  174.  
  175.  
  176.  
  177.  
  178.  
  179.                                       3    
  180.  
  181.  
  182. Calling TCXL Functions from Assembly Language.
  183.  
  184.  
  185.     Most of TCXL's functions (excluding macro-functions) can be called by
  186. assembly language.  Some functions will require the Turbo C CS.LIB library to
  187. be linked in also.  Any TCXL function which calls the Turbo C malloc() function
  188. cannot be called by an assembly program because malloc() needs information from
  189. the C0S.OBJ startup code.  Functions that use malloc() include some string
  190. functions, screen save/restore functions, and windowing functions.
  191.   
  192.     Turbo C passes its arguments to a function via the stack.  Arguments are
  193. pushed onto the stack in reverse order.  Turbo C places the underscore symbol
  194. preceeding the function name, so to call the getns() function, you must call it
  195. by _getns.  After the call to the function, you must readjust the stack.  For
  196. every push on the stack, the stack pointer needs to be incremented by 2.  The
  197. return value (if any) will be in the AX register.  Functions that return 16-bit
  198. values will have the high value in DX and the low value in AX.  Here's an
  199. example for the getns() function:
  200.  
  201.             EXTRN   _getns:NEAR         ; so assembler won't flag an error
  202.             mov     ax,30               ; maximum length of input string
  203.             push    ax                  ; push it onto the stack
  204.             mov     ax,OFFSET straddr   ; address of string to receive input
  205.             push    ax                  ; push it onto the stack
  206.             call    _getns              ; call the function
  207.             add     sp,4                ; adjust stack 2 for every argument
  208.             or      ax,ax               ; is return value = 0?
  209.             jnz     exitprog            ; no, Esc was pressed, exit program
  210.             (rest of program)
  211.  
  212.     Here's how to assemble and link your assembly language program with the
  213. TCXL function library:
  214.  
  215.         1.  Assemble your assembly source code file with the case-sensitive
  216.             switch on:
  217.  
  218.                 masm /mx myfile ;
  219.  
  220.         2.  Link your object file specifying TCXL as a library:
  221.  
  222.                 link myfile,,,tcxl cs
  223.  
  224.         3.  Convert to a .COM file if applicable:
  225.  
  226.                 exe2bin myfile myfile.com
  227.  
  228.  
  229.  
  230.  
  231.  
  232.  
  233.  
  234.  
  235.  
  236.  
  237.  
  238.  
  239.                                       4    
  240.  
  241.  
  242. Using TCXL's Windowing Functions.
  243.  
  244.  
  245.     TCXL has a a powerful windowing system that can be very useful in an
  246. application program.  All windowing functions are prefixed with a 'w'.  The
  247. windowing is controlled by TCXL's window manager which is called by every
  248. windowing function.  The window manager keeps track of which window is active;
  249. each window's position, cursor location, attributes, etc.; how many windows are
  250. open; and other information.  All windowing functions set the _werrno global
  251. variable before returning.  The literal value of this variable can be viewed
  252. by calling the werrmsg() function.
  253.  
  254.     You may open as many windows as memory permits.  Once a window is opened,
  255. it immediately becomes the active window.  TCXL's windowing functions can only
  256. be performed on the active window.  If you want to perform a function on a
  257. inactive window, you must activate it first.  See the supplied TCXLDEMO.C
  258. program for a complete example of how to use the windowing system.
  259.  
  260.  
  261.     Example:
  262.  
  263.         int w1,w2;                              /*  window handles  */
  264.         w1=wopen(0,0,10,40,0,LCYAN|_BLUE);      /*  open 1st window  */
  265.         if(!w1) error_routine();                /*  check for error  */
  266.         waitkey();                              /*  wait for keypress  */
  267.         wputs("Hello, ");
  268.         waitkey();                              /*  wait for keypress  */
  269.         w2=wopen(7,20,18,60,2,LRED|_MAGENTA);   /*  open 2nd window  */
  270.         if(!w2) error_routine();                /*  check for error  */
  271.         wputs("Hello, ");
  272.         waitkey();                              /*  wait for keypress  */
  273.         if(wactiv(w1)) error_routine();         /*  activate 1st window  */
  274.         wputs("there");
  275.         waitkey();                              /*  wait for keypress  */
  276.         if(wactiv(w2)) error_routine();         /*  activate 2nd window  */
  277.         wputs("there");
  278.         waitkey();                              /*  wait for keypress  */
  279.         wclose();                               /*  close 2nd window  */
  280.         waitkey();                              /*  wait for keypress  */
  281.         wclose();                               /*  close 1st window  */
  282.  
  283.  
  284.  
  285.  
  286.  
  287.  
  288.  
  289.  
  290.  
  291.  
  292.  
  293.  
  294.  
  295.  
  296.  
  297.  
  298.  
  299.                                       5    
  300.  
  301.  
  302. Using TCXL's Expanded Memory Specification (EMS) Functions.
  303.  
  304.  
  305.     TCXL contains several functions for simple management of expanded memory.
  306. All of TCXL's EMS functions are prefixed with 'ems'.  For those not familiar
  307. with expanded memory, I will briefly explain it.
  308.  
  309.     The 8088 microprocessor is only able to address 1 Megabyte of memory.  When
  310. applications started needing more memory, Lotus, Intel, and Microsoft developed
  311. the Expanded Memory Specification.  This specification allows access to more
  312. than 1 Megabyte of memory by mapping 16K 'windows' of memory on an expanded
  313. memory board in and out of an unused area of DOS memory.  The Expanded Memory
  314. Manager (EMM) is a software driver that controls the mapping.
  315.  
  316.     Physical pages are 16K blocks of memory which are located in an unused area
  317. of DOS memory.  There are typically 4 physical pages comprising a 64K
  318. contiguous area of mappable DOS memory.  The EMS page frame base address points
  319. to the beginning of the first physical page. Logical pages are 16K blocks of
  320. memory on the expanded memory board.  There can be as many logical pages as the
  321. expanded memory board has, up to 8 Megabytes.
  322.  
  323.     Every program that uses expanded memory must do the following:
  324.  
  325.         1.  determine if the EMM device driver is loaded
  326.         2.  determine if there are enough free pages for its application
  327.         3.  allocate pages of expanded memory
  328.         4.  find out what the EMS page frame base address is
  329.         5.  map logical pages onto physical pages
  330.         6.  deallocate pages when finished with them
  331.  
  332.     Here's an example of using TCXL's EMS functions to perform these
  333. procedures:
  334.  
  335.         int handle1,handle2;
  336.         char buf[14];
  337.         if(!emsexist()) {                   /* check for the EMM driver      */
  338.             printf("EMM not loaded\n");
  339.             exit(1);
  340.         }
  341.         handle1=emsalloc(2);                /* request 2 pages of EMS memory */
  342.         handle2=emsalloc(2);                /* request 2 more pages          */
  343.         if((!emsh1)||(!emsh2)) {            /* test for allocation error     */
  344.             printf("EMS allocation error\n");
  345.             exit(1);
  346.         }
  347.         emsmap(handle1,0,0);                /* map logical page 0 of handle 1
  348.                                                to physical page 0            */
  349.         emswrite("Hello, world",0,13);      /* write a string at offset 0,
  350.                                                automatically determines what
  351.                                                the page frame address is     */
  352.         emsmap(emsh2,0,0);                  /* map logical page 0 of handle 2
  353.                                                to physical page 0            */
  354.         emswrite("How are you?",0,13);      /* write a string at offset 0    */
  355.         emsmap(handle1,0,0);                /* map logical page 0 of handle 1
  356.                                                to physical page 0            */
  357.  
  358.  
  359.                                       6    
  360.         emsread(buf,0,13);                  /* read 13 bytes from offset 0
  361.                                                into buffer                   */
  362.         printf("buf = %s\n",buf);           /* display buffer contents       */
  363.         emsmap(handle2,0,0);                /* map logical page 0 of handle 2
  364.                                                to physical page 0            */
  365.         emsread(buf,0,13);                  /* read 13 bytes from offset 0
  366.                                                into buffer                   */
  367.         printf("buf = %s\n",buf);           /* display buffer contents       */
  368.         emsdealloc(handle2);                /* deallocate pages belonging to
  369.                                                handle 2                      */
  370.         emsdealloc(handle1);                /* deallocate pages belonging to
  371.                                                handle 1                      */
  372.  
  373.  
  374.  
  375.  
  376.  
  377.  
  378.  
  379.  
  380.  
  381.  
  382.  
  383.  
  384.  
  385.  
  386.  
  387.  
  388.  
  389.  
  390.  
  391.  
  392.  
  393.  
  394.  
  395.  
  396.  
  397.  
  398.  
  399.  
  400.  
  401.  
  402.  
  403.  
  404.  
  405.  
  406.  
  407.  
  408.  
  409.  
  410.  
  411.  
  412.  
  413.  
  414.  
  415.  
  416.  
  417.  
  418.  
  419.                                       7    
  420.  
  421.  
  422. Using TCXL's inputsf() and winputsf() Functions.
  423.  
  424.  
  425.     The inputsf() and winputsf() functions in TCXL accept keyboard input
  426. through the use of TCXL's own input format strings.  These format strings are
  427. not the same as what scanf() uses.  They have the ability to restrict and
  428. convert input for each character received from the keyboard.  They also allow
  429. for custom prompts between each character input.  The format control characters
  430. can be in any order in the string, but all letters must be in the case shown
  431. here.  Invalid control characters will cause the function to return an error
  432. and the receiving string will be null. Spaces can be used to improve
  433. readability of the format string.  If the Escape key is not disabled, when
  434. pressed it will return an error code and the receiving string will be null.
  435. Valid control characters are:
  436.  
  437.             !.......!   - start and end exclamation points, any letters
  438.                           between them are format command toggles.  The
  439.                           valid format command toggles are:
  440.  
  441.                             -   - decreases text attribute, works with
  442.                                   winputsf() only
  443.  
  444.                             +   - increases text attribute, works with
  445.                                   winputsf() only
  446.  
  447.                             C   - toggles copying of display (quoted)
  448.                                   characters to the receiving string.
  449.                                   (default is off)
  450.  
  451.                             E   - toggles Escape key checking off/on.
  452.                                   When off, if the Escape key is pressed,
  453.                                   the function returns an error code and
  454.                                   the string will be null.   The default
  455.                                   for inputsf() is on.  For winputsf(),
  456.                                   the default is the value of _wesc upon
  457.                                   calling.
  458.  
  459.                             L   - toggles lower-case conversion.  When on,
  460.                                   the case of input letters will be forced
  461.                                   to lower case.  (default is off)
  462.  
  463.                             M   - toggles mixed-case conversion.  When on,
  464.                                   the case of input letters will be forced
  465.                                   to upper-case for the first letter of
  466.                                   each word and lower-case for the
  467.                                   remaining letters.  (default is off)
  468.  
  469.                             R   - toggles return key checking.  When off,
  470.                                   the carriage return key will be ignored
  471.                                   until the end of the format string.
  472.                                   (default is on)
  473.  
  474.                             U   - toggles upper-case conversion.  When on,
  475.                                   the case of input letters will be forced
  476.                                   to upper-case.  (default is off)
  477.  
  478.  
  479.                                       8    
  480.  
  481.  
  482.             '.......'   - start and end single quotes, any characters
  483.                           between them will be displayed as text.  If the 'C'
  484.                           command toggle is on, the characters will also be
  485.                           copied to the receiving string.
  486.  
  487.             Character type codes:
  488.  
  489.             #   - accept numeric character '0' thru '9'
  490.             9   - accept numeric character '0' thru '9', '.', '-', and '+'
  491.             ?   - accept any character
  492.             A   - accept alpha character 'A' thru 'Z', 'a' thru 'z', and space
  493.             L   - accept alpha character 'A' thru 'Z', 'a' thru 'z', and space
  494.                   input character will be converted to lower case
  495.             M   - accept alpha character 'A' thru 'Z', 'a' thru 'z', and space
  496.                   input character will be converted to mixed case
  497.             P   - accept printable character (ASCII 20 thru 7E)
  498.             U   - accept alpha character 'A' thru 'Z', 'a' thru 'z', and space
  499.                   input character will be converted to upper case
  500.             X   - accept alphanumeric character 'A' thru 'Z', 'a' thru 'z',
  501.                   '0' thru '9', and space
  502.             Y   - accept a yes/no character 'Y', 'y', 'N', and 'n'
  503.  
  504.  
  505.             <.......>   - start and end angle brackets, accept a character
  506.                           from valid list of characters between angle brackets.
  507.  
  508.     Examples:
  509.  
  510.         inputsf(str,"'Enter name:  ' !UR! XXXXX !R! XXXXXXXXXX");
  511.  
  512.             Prompts for name, inputs string from keyboard converting characters
  513.             to upper case as it goes, allows up to 15 alphanumeric characters
  514.             as input.  The return key is disabled until at least 5 characters
  515.             have been entered.  Characters will be copied to str.  This space
  516.             must already be allocated!
  517.  
  518.  
  519.         inputsf(str,"!R! 'Enter phone:  '!C! '(' ### ') ' ### '-' ####");
  520.  
  521.             Prompts for a full phone number including area code, allows only
  522.             digit characters and displays format punctuation as it goes.  The
  523.             entire field must be filled before return can be pressed.  All of
  524.             the characters except the prompt will be copied to the receiving
  525.             string.  The input string will be copied to str, which must have
  526.             already been allocated.
  527.  
  528.  
  529.         inputsf(str,"!R!'Enter SSAN:  '<0123456>##'-'##'-'####");
  530.  
  531.             Prompts for a Social Security number.  Will not allow return to be
  532.             pressed until all digits have been entered.  The first digit of the
  533.             SSAN must be 0 - 6. Dashes will be displayed as you are typing in
  534.             the data, but will not be contained in the receiving string str.
  535.  
  536.  
  537.  
  538.  
  539.                                       9    
  540.         inputsf(str,"!R!'Enter DOB (MM/DD/YY):  '<01>#'/'<0123>#'/'##");
  541.  
  542.             Prompts for Date of Birth.  Allows only valid digits for the input
  543.             date.  Prevents the return key from working until all digits have
  544.             been typed in.
  545.  
  546.  
  547.  
  548.  
  549.  
  550.  
  551.  
  552.  
  553.  
  554.  
  555.  
  556.  
  557.  
  558.  
  559.  
  560.  
  561.  
  562.  
  563.  
  564.  
  565.  
  566.  
  567.  
  568.  
  569.  
  570.  
  571.  
  572.  
  573.  
  574.  
  575.  
  576.  
  577.  
  578.  
  579.  
  580.  
  581.  
  582.  
  583.  
  584.  
  585.  
  586.  
  587.  
  588.  
  589.  
  590.  
  591.  
  592.  
  593.  
  594.  
  595.  
  596.  
  597.  
  598.  
  599.                                       10   
  600.  
  601.  
  602. Using TCXL's Multi-Field Window Input Functions.
  603.  
  604.  
  605.     Two functions are needed to process multi-field keyboard input from
  606. windows:  winpdef(), and winpread().  The winpdef() function sets up an input
  607. field.  For every input field you want defined, you must call winpdef().  It
  608. displays the current contents of what is to be the receiving string. The size
  609. of the string before winpdef() is called will be the size of the input field.
  610. You may need to resize the string before calling winpdef().  You can do this
  611. with the strsetsz() function.  The winpdef() function will also specify the
  612. type of the field.  Valid field types are:
  613.  
  614.         #   - allow only numeric characters '0' thru '9'
  615.         9   - allow only numeric characters '0' thru '9', '.', '-', and '+'
  616.         ?   - allow any characters
  617.         A   - allow only alpha characters 'A' thru 'Z', 'a' thru 'z', and space
  618.         L   - allow only alpha characters 'A' thru 'Z', 'a' thru 'z', and space
  619.               input characters will be converted to lower case
  620.         M   - allow only alpha characters 'A' thru 'Z', 'a' thru 'z', and space
  621.               input characters will be converted to mixed case
  622.         P   - allow only printable characters (ASCII 20 thru 7E)
  623.         U   - allow only alpha characters 'A' thru 'Z', 'a' thru 'z', and space
  624.               input characters will be converted to upper case
  625.         X   - allow only alphanumeric characters 'A' thru 'Z', 'a' thru 'z',
  626.               '0' thru '9', and space
  627.         Y   - allow only yes/no characters 'Y', 'y', 'N', and 'n'
  628.  
  629.     The case of the field type characters must be as shown.  For every input
  630. field you want defined, you must call winpdef().
  631.  
  632.     The winpread() function processes all fields defined with winpdef().  The
  633. user is allowed to move around and edit all of the fields.  Valid editing keys
  634. are:
  635.  
  636.         LeftArrow   - moves cursor left inside the field
  637.         RightArrow  - moves cursor right inside the field
  638.         UpArrow     - moves cursor to the previous field up
  639.         DownArrow   - moves cursor to the next field down
  640.         Tab         - moves cursor to the next field right
  641.         Shift-Tab   - moves cursor to the next field left
  642.         Enter       - if the cursor is in the last field on the screen, it will
  643.                       process all fields.  Otherwise it will skip to the next
  644.                       field
  645.         Ctrl-Enter  - processes all fields, wherever the cursor may be
  646.         Home        - moves cursor to beginning of field
  647.         End         - moves cursor to end of field
  648.         Ctrl-Home   - moves cursor to the beginning of the first field on the
  649.                       screen
  650.         Ctrl-End    - moves cursor to the end of the last field on the screen
  651.         Ins         - inserts a space at cursor location.  All text to the
  652.                       right of the cursor will be shifted right.  The end
  653.                       character will be dropped.
  654.         Del         - deletes character at the cursor location.  All text to
  655.                       the right of the cursor will be shifted left and a space
  656.                       will be inserted at the end of the field.
  657.  
  658.  
  659.                                       11   
  660.         Esc         - if enabled, cancels input and returns a W_ESCPRESS value.
  661.                       Escape checking can be enabled or disabled by using the
  662.                       wsetesc() function before winpread() is called.
  663.  
  664.     After the winpread() function is called, all fields defined with winpdef()
  665. will be cleared.  The receiving strings of all defined fields will now contain
  666. the data entered.  If Escape checking was on and the Esc key was pressed, then
  667. all receiving strings will contain the values they held before winpread() was
  668. called.
  669.  
  670.     Another function that can be used in multi-field keyboard input is the
  671. winpxcel() function.  What this does is cancel all fields defined with
  672. winpdef().  For winpxcel() to have any effect, it must be called before
  673. winpread() is.
  674.  
  675.  
  676.  
  677.  
  678.  
  679.  
  680.  
  681.  
  682.  
  683.  
  684.  
  685.  
  686.  
  687.  
  688.  
  689.  
  690.  
  691.  
  692.  
  693.  
  694.  
  695.  
  696.  
  697.  
  698.  
  699.  
  700.  
  701.  
  702.  
  703.  
  704.  
  705.  
  706.  
  707.  
  708.  
  709.  
  710.  
  711.  
  712.  
  713.  
  714.  
  715.  
  716.  
  717.  
  718.  
  719.                                       12   
  720.  
  721.  
  722. Using TCXL's Window Bar-Selection Menus.
  723.  
  724.  
  725.     Two functions are needed to use TCXL's bar-selection menus:  wmbardef(),
  726. and wmbarget().  The wmbardef() function displays the menu option on the
  727. screen and assigns a tag character to it.  The tag character is used for
  728. identification of the menu option.  The tag character must be alphanumeric and
  729. is case insensitive.  For every menu option you have, the wmbardef() function
  730. must be called.
  731.  
  732.     When all menu options have been defined, you will call the wmbarget()
  733. function.  The first argument to wmbarget() is the attribute of the selection
  734. bar.  The second argument is the tag character of where you want the selection
  735. bar to initially be located.  If an undefined tag character is used, then the
  736. initial position of the selection bar will default to the upper-leftmost
  737. option.  The third argument of wmbarget() is the pulldown parameter.  This is
  738. used for a pull-down menu system.  If a pull-down menu system is not being
  739. used, then the pulldown parameter should be specified as zero.
  740.  
  741.     If you are using pull-down menus, then the pulldown parameter may have
  742. one of four values.  PDMAIN is used to signify that the menu you have just
  743. defined is to be the main menu of a pull-down menu system.  PDMENU is used to
  744. signify that the menu you have just defined is one of the pull-down menus from
  745. the main menu.  The other two values that the pulldown parameter can have are
  746. used for movement between pull-down menus.  PDPREV is used to signify that the
  747. menu you have just defined is the main menu and you wish to automatically
  748. select the option previous to the specified taginit.  PDNEXT is used to signify
  749. that the menu you have just defined is the main menu and you wish to
  750. automatically select the next option after the specified taginit.
  751.  
  752.     Movement/selection keys that are used during the wmbarget() function are:
  753.  
  754.         LeftArrow   - moves selection bar to previous option left.  If inside a
  755.                       pull-down menu, pressing this will cause wmbarget() to
  756.                       return PDPREV.
  757.         RightArrow  - moves selection bar to next option right.  If inside a
  758.                       pull-down menu, pressing this will cause wmbarget() to
  759.                       return PDNEXT.
  760.         UpArrow     - moves selection bar to previous option up.
  761.         DownArrow   - moves selection bar to next option down.  If pull-down
  762.                       menus are being used and you are currently in the main
  763.                       menu, then the option that the selection bar is on is
  764.                       selected.
  765.         Tab         - moves selection bar to next option right.
  766.         Shift-Tab   - moves selection bar to previous option left.
  767.         Enter       - selects the option that the selection bar is on.
  768.         Home        - moves selection bar to upper left option.
  769.         End         - moves selection bar to lower right option.
  770.         Esc         - if enabled, cancels input and returns a zero.  Escape
  771.                       checking can be enabled or disabled by using the
  772.                       wsetesc() function before wmbarget() is called.  If
  773.                       inside a pull-down menu, pressing this will cause
  774.                       wmbarget() to return PDMAIN.
  775.  
  776.     When an option is selected, it's tag character will be returned by
  777.  
  778.  
  779.                                       13   
  780. wmbarget().  The tag character will be in the same case as when defined.  If
  781. the Esc key was pressed and Escape checking was on, a zero will be returned and
  782. the global variable _werrno will be set to W_ESCPRESS.  If any other error
  783. occurred, the return value will be zero and the global variable _werrno will be
  784. set to an error code (see TCXLWIN.H).  Once a selection is made, the wmbarget()
  785. function automatically clears all menu options defined by wmbardef().
  786.  
  787.   If you are using wmbarget() to process a pull-down menu (PDMENU), and the
  788. LeftArrow or RightArrow key is pressed, then wmbarget() will return PDPREV or
  789. PDNEXT, respectively.  This allows you to input these return values back into
  790. the main menu's wmbarget() pulldown parameter to automatically select the
  791. previous or next pull-down window from the current pull-down window.  The
  792. Escape checking status will be ignored while using pull-down menus.  Instead,
  793. if in a pull-down menu (PDMENU), and the Esc key is pressed, wmbarget() will
  794. return PDMAIN, which allows you to reinput that value back into the main menu's
  795. wmbarget() pulldown parameter.  For a complete example of using pull-down
  796. menus, see the example in TCXLDEMO.C.
  797.  
  798.     Another function that may be used for bar-selection menus is wmbarxcel().
  799. This can be used if you need to cancel all defined options before wmbarget() is
  800. called.
  801.  
  802. Example for a Bar-Selection Menu:
  803.  
  804.         int selection;
  805.         wopen(5,10,20,50,4,LMAGENTA|_RED);
  806.         wmbardef(2,2,LGREEN|_RED,"Add record",'A');
  807.         wmbardef(4,2,LGREEN|_RED,"Delete record",'D');
  808.         wmbardef(6,2,LGREEN|_RED,"Print record",'P');
  809.         wmbardef(8,2,LGREEN|_RED,"Update record",'U');
  810.         selection=wmbarget(LRED|_GREEN,'A',0);
  811.         wgotoxy(10,2);
  812.         wprintf("You selected %c\n",selection);
  813.         waitkey();
  814.         wclose();
  815.  
  816.  
  817.  
  818.  
  819.  
  820.  
  821.  
  822.  
  823.  
  824.  
  825.  
  826.  
  827.  
  828.  
  829.  
  830.  
  831.  
  832.  
  833.  
  834.  
  835.  
  836.  
  837.  
  838.  
  839.                                       14   
  840.  
  841.  
  842. Using TCXL's Mouse Functions.
  843.  
  844.  
  845.     TCXL has several functions used to facilitate Microsoft compatible mice.
  846. All of these functions are prefixed with a 'ms'.  These functions will work
  847. on Microsoft mice or other mice using a Microsoft compatible driver.  These
  848. mouse functions allow you to:
  849.  
  850.         1.  Initialize mouse/determine if mouse exists.
  851.         2.  Get the status of button presses/releases.
  852.         3.  Hide/reveal the mouse cursor.
  853.         4.  Get/set the mouse cursor position.
  854.         5.  Select type of mouse cursor (hardware or software).
  855.         5.  Adjust the mouse sensitivity (speed).
  856.         6.  Get information on direction of mouse movement.
  857.         7.  Establish horizontal/vertical boundries of mouse movement.
  858.  
  859.     When reading or setting mouse coordinates, the values used are in pixels.
  860. To calculate mouse coordinates in terms of column and row instead of X and Y,
  861. you would multiply character width by column, and character height by row.
  862. Typically, screen characters are 8 pixels wide by 8 pixels tall.  So, to
  863. position the mouse cursor at column 60, row 15, you would use:
  864.  
  865.         msgotoxy(60*8,15*8);
  866.  
  867.     The mscursor() function sets the cursor type.  It takes 3 parameters:
  868. ctype, smask, and cmask.  If ctype = 1 then the cursor type is hardware.  The
  869. hardware cursor is the flashing block on your screen.  If this type of cursor
  870. is used, it will interfere with normal text cursor functions.  When using the
  871. hardware cursor type, the value for smask is the start scan line of the cursor,
  872. and the value for cmask is the stop scan line of the cursor.  If the ctype
  873. parameter = 0, then a software cursor is used.  For the software cursor, the
  874. smask parameter is the screen mask, and the cmask parameter is the cursor mask.
  875. The screen mask determines which of the characters attributes are preserved.
  876. The cursor mask defines how the attributes are changed to show the cursor.  For
  877. both masks, the bit values are as follows:
  878.  
  879.         Bits 0-7:       ASCII value of character
  880.         Bits 8-10:      Foreground color
  881.         Bit 11:         Intensity
  882.         Bits 12-14:     Background color
  883.         Bit 15:         Blink
  884.  
  885.     The msmotion() function determines direction and distance traveled since
  886. last msmotion() call.  The xcount and ycount parameters will either be negative
  887. or positive depending on direction mouse moved.  The amount will be the number
  888. of pixels travelled.
  889.  
  890.     When updating the screen, the mouse cursor should be hidden with the
  891. mshidecur() function first, and then after the screen is updated, the
  892. msshowcur() should be called to re-display the mouse cursor.
  893.  
  894.  
  895.  
  896.  
  897.  
  898.  
  899.                                       15   
  900.  
  901.  
  902.                        Description of TCXL Functions
  903.                        -----------------------------
  904.  
  905.  
  906. Name:       attrib
  907. Purpose:    creates an attribute
  908. Prototype:  int attrib(int fore,int back,int bright,int blink);
  909. Header:     tcxlvid.h  tcxlwin.h
  910. Inputs:     fore    - foreground color code (0-7)
  911.             back    - background color code (0-7)
  912.             bright  - intensity (0-1)
  913.             blink   - blinking (0-1)
  914. Return:     attribute
  915. Also see:   setattr wtextattr
  916. Example:
  917.             prints(15,10,attrib(7,5,1,0),"Hello, world");
  918.  
  919.  
  920. Name:       beep
  921. Purpose:    sounds a beep in the speaker
  922. Prototype:  void beep(void);
  923. Header:     tcxldef.h
  924. Inputs:     none
  925. Return:     none
  926. Also see:   sound_
  927. Example:
  928.             beep();
  929.  
  930.  
  931. Name:       biosver
  932. Purpose:    returns the ROM BIOS version date
  933. Prototype:  char *biosver(void);
  934. Header:     tcxldef.h
  935. Inputs:     none
  936. Return:     address of the static string containing the ROM BIOS version date
  937. Also see:   machid
  938. Example:
  939.             printf("ROM BIOS version date is %s\n",biosver());
  940.  
  941.  
  942. Name:       box
  943. Purpose:    draws a box on the screen
  944. Prototype:  void box(int srow,int scol,int erow,int ecol,int btype,int atr);
  945. Header:     tcxlvid.h
  946. Inputs:     srow    - starting row upper left corner
  947.             scol    - starting column upper left corner
  948.             erow    - ending row lower right corner
  949.             ecol    - ending column
  950.             btype   - box type (0-5)
  951.             atr     - attribute
  952. Return:     none
  953. Also see:   attrib boxd
  954. Example:
  955.             box(0,0,22,79,1,WHITE|_BLUE);
  956.  
  957.  
  958.  
  959.                                       16   
  960.  
  961. Name:       boxd
  962. Purpose:    draws a box directly on the screen (no BIOS calls)
  963. Prototype:  void boxd(int srow,int scol,int erow,int ecol,int btype,int atr);
  964. Header:     tcxlvid.h
  965. Inputs:     srow    - starting row upper left corner
  966.             scol    - starting column upper left corner
  967.             erow    - ending row lower right corner
  968.             ecol    - ending column
  969.             btype   - box type (0-5)
  970.             atr     - attribute
  971. Return:     none
  972. Also see:   attrib box videoinit
  973. Example:
  974.             boxd(0,0,22,79,1,WHITE|_BLUE);
  975.  
  976.  
  977. Name:       capsoff
  978. Purpose:    toggles the CapsLock key off
  979. Prototype:  void capsoff(void);
  980. Header:     tcxlkey.h
  981. Inputs:     none
  982. Return:     none
  983. Also see:   capson kbstat numoff
  984. Example:
  985.             capsoff();
  986.  
  987.  
  988. Name:       capson
  989. Purpose:    toggles the CapsLock key on
  990. Prototype:  void capson(void);
  991. Header:     tcxlkey.h
  992. Inputs:     none
  993. Return:     none
  994. Also see:   capsoff kbstat numon
  995. Example:
  996.             capson();
  997.  
  998.  
  999. Name:       clearkeys
  1000. Purpose:    clears the keyboard buffer
  1001. Prototype:  void clearkeys(void);
  1002. Header:     tcxlkey.h
  1003. Inputs:     none
  1004. Return:     none
  1005. Also see:   waitkey
  1006. Example:
  1007.             int ch;
  1008.             printf("Press a key:  ");
  1009.             clearkeys();
  1010.             ch=getche();
  1011.  
  1012.  
  1013. Name:       clockcal
  1014. Purpose:    determines if a clock-calendar board is installed (usually this
  1015.             board will only be in XT machines)
  1016. Prototype:  int clockcal(void);
  1017.  
  1018.  
  1019.                                       17   
  1020. Header:     tcxldef.h
  1021. Inputs:     none
  1022. Return:     a non-zero value if a clock-calendar board is present
  1023. Example:
  1024.             printf("A clock-calendar is%s installed\n",clockcal()?"":" not");
  1025.  
  1026.  
  1027. Name:       clreol_
  1028. Purpose:    clears to the end of line using current attribute
  1029. Prototype:  void clreol_(void);
  1030. Header:     tcxlvid.h
  1031. Inputs:     none
  1032. Return:     none
  1033. Also see:   clrscrn clrwin
  1034. Example:
  1035.             prints(10,5,LCYAN|_BLUE,"Hello, worldXXXXXXXX");
  1036.             gotoxy_(10,17);
  1037.             clreol_();
  1038.  
  1039.  
  1040. Name:       clrscrn
  1041. Purpose:    clears the screen (up to 50 lines) using current attribute, and
  1042.             homes the cursor
  1043. Prototype:  void clrscrn(void);
  1044. Header:     tcxlvid.h
  1045. Inputs:     none
  1046. Return:     none
  1047. Also see:   clreol_ clrwin
  1048. Example:
  1049.             clrscrn();
  1050.  
  1051.  
  1052. Name:       clrwin
  1053. Purpose:    clears a window of the screen using current attribute
  1054. Prototype:  void clrwin(srow,scol,erow,ecol);
  1055. Header:     tcxlvid.h
  1056. Inputs:     srow    - starting row upper left corner
  1057.             scol    - starting column upper left corner
  1058.             erow    - ending row lower right corner
  1059.             ecol    - ending column lower right corner
  1060. Return:     none
  1061. Also see:   clreol_ clrscrn
  1062. Example:
  1063.             filld(10,10,20,20,'X',LCYAN|_BLUE);
  1064.             clrwin(11,11,19,19);
  1065.  
  1066.  
  1067. Name:       cvaltype
  1068. Purpose:    checks given character against given character type code,
  1069.             determines if character is valid type
  1070. Prototype:  int cvaltype(int ch,int ctype);
  1071. Header:     tcxlstr.h
  1072. Inputs:     ch      - character to test
  1073.             ctype   - character type code to compare with, see section on TCXL
  1074.                       format strings for a list of valid character type codes.
  1075. Return:     a 1 if character is a valid character type, otherwise a zero
  1076. Also see:   winpdef
  1077.  
  1078.  
  1079.                                       18   
  1080. Example:
  1081.             int valid=NO;
  1082.             char ch='Z';
  1083.             valid=cvaltype(ch,'#');
  1084.             printf("%c is %sa valid char of type '#'\n",ch,valid?"":" not");
  1085.  
  1086.  
  1087. Name:       delay_
  1088. Purpose:    delays program execution for a specified duration
  1089. Prototype:  void delay_(unsigned duration);
  1090. Header:     tcxldef.h
  1091. Inputs:     duration    - duration (0-65535) ie. 18 = 1 second
  1092. Return:     none
  1093. Also see:   timer waitkeyt
  1094. Example:
  1095.             printf("Testing\n1\n");
  1096.             delay_(36);
  1097.             printf("2\n");
  1098.             delay_(36);
  1099.             printf("3\n");
  1100.  
  1101.  
  1102. Name:       disktoscrn
  1103. Purpose:    copies a previously saved screen disk file back to the screen
  1104. Prototype:  int disktoscrn(char *fname);
  1105. Header:     tcxldsk.h tcxlvid.h
  1106. Inputs:     fname   - address of the string containing file name to read from
  1107. Return:     a zero if no error
  1108. Also see:   disktowin fexist scrntodisk
  1109. Example:
  1110.             if(disktoscrn("SCREEN.DAT")) {
  1111.                 printf("Error reading input file\n");
  1112.                 exit(1);
  1113.             }
  1114.  
  1115.  
  1116. Name:       disktowin
  1117. Purpose:    copies a previously saved window disk file back to the screen
  1118. Prototype:  int disktowin(char *fname);
  1119. Header:     tcxldsk.h
  1120. Inputs:     fname   - address of the string containing file name to read from
  1121. Return:     a zero if no error
  1122. Also see:   disktoscrn fexist wintodisk
  1123. Example:
  1124.             if(disktowin("WINDOW.DAT")) {
  1125.                 printf("Error reading input file\n");
  1126.                 exit(1);
  1127.             }
  1128.  
  1129.  
  1130. Name:       emsalloc
  1131. Purpose:    allocates pages of EMS memory.  See the section on using TCXL's EMS
  1132.             functions for more information
  1133. Prototype:  unsigned emsalloc(int numpages);
  1134. Header:     tcxlems.h
  1135. Inputs:     numpages  - the number of pages (16K blocks) requested
  1136. Return:     the EMS handle or a 0 if an error occurred
  1137.  
  1138.  
  1139.                                       19   
  1140. Also see:   emsdealloc emsexist emsfree
  1141. Example:
  1142.             int handle1;
  1143.             handle1=emsalloc(2);        /*  request 2 pages (32K)   */
  1144.             if(!handle1) {
  1145.                 printf("EMS allocation error\n");
  1146.                 exit(1);
  1147.             }
  1148.  
  1149.  
  1150. Name:       emsdealloc
  1151. Purpose:    deallocate previously allocated pages of EMS memory
  1152. Prototype:  int emsdealloc(int handle);
  1153. Header:     tcxlems.h
  1154. Inputs:     handle  - the previously assigned EMS handle
  1155. Return:     a 0 if no error or else an EMS error code
  1156. Also see:   emsalloc
  1157. Example:
  1158.             if(emsdealloc(ems_handle)) {
  1159.                 printf("EMS deallocation error\n");
  1160.                 exit(1);
  1161.             }
  1162.  
  1163.  
  1164. Name:       emsexist
  1165. Purpose:    determines if the EMS device driver is loaded.  See the section on
  1166.             using TCXL's EMS functions for more information
  1167. Prototype:  int emsexist(void);
  1168. Header:     tcxlems.h
  1169. Inputs:     none
  1170. Return:     a 0 if EMS driver not loaded, or a 1 if EMS driver is loaded
  1171. Also see:   emsalloc emsfree emstotal expmem
  1172. Example:
  1173.             printf("EMS device driver is %sloaded\n",(emsexist())?"":"not ");
  1174.  
  1175.  
  1176. Name:       emsframe
  1177. Purpose:    returns the EMS page frame base address (segment)
  1178. Prototype:  unsigned emsframe(void);
  1179. Header:     tcxlems.h
  1180. Inputs:     none
  1181. Return:     the EMS page frame base address (segment) or a zero if an error
  1182.             occurred
  1183. Also see:   emsmap
  1184. Example:
  1185.             printf("EMS page frame address is at:  %X\n",emsframe());
  1186.  
  1187.  
  1188. Name:       emsfree
  1189. Purpose:    returns the number of free EMS pages (16K blocks)
  1190. Prototype:  unsigned emsfree(void);
  1191. Header:     tcxlems.h
  1192. Inputs:     none
  1193. Return:     the number of free EMS pages
  1194. Also see:   emsalloc emstotal
  1195. Example:
  1196.             printf("Free EMS pages:  %d\n",emsfree());
  1197.  
  1198.  
  1199.                                       20   
  1200.  
  1201.  
  1202. Name:       emsmap
  1203. Purpose:    maps a logical EMS page onto a physical page address, emsalloc()
  1204.             must be called prior to this function
  1205. Prototype:  int emsmap(int handle,int lpage,int ppage);
  1206. Header:     tcxlems.h
  1207. Inputs:     handle  - the EMS handle previosly assigned
  1208.             lpage   - the logical EMS page to map (0 - ?)
  1209.             ppage   - the physical DOS page to map to (0 - 3)
  1210. Return:     a zero if no error, or else an EMS error code
  1211. Also see:   emsalloc emsframe
  1212. Example:
  1213.             if(emsmap(ems_handle,0,0)) {
  1214.                 printf("Error mapping logical page 0 to physical page 0\n");
  1215.                 exit(1);
  1216.             }
  1217.  
  1218.  
  1219. Name:       emsread
  1220. Purpose:    reads bytes from an EMS page(s), emsalloc() and emsmap() must be
  1221.             called prior to this function.  The source segment used will be
  1222.             the current EMS page frame address and the destination segment will
  1223.             be the program's DATA segment.
  1224. Prototype:  int emsread(void *dest,unsigned emsofs,unsigned numbytes);
  1225. Header:     tcxlems.h
  1226. Inputs:     dest     - address to receive bytes read
  1227.             emsofs   - offset from the EMS page frame base address at which to
  1228.                        read the bytes from
  1229.             numbytes - the number of bytes to read
  1230. Return:     a zero if no error, otherwise an error
  1231. Also see:   emsmap emswrite
  1232. Example:
  1233.             if(!emsread(buf,0x100,64)) {
  1234.                 printf("Failed to read 64 bytes from EMS memory\n");
  1235.                 exit(1);
  1236.             }
  1237.  
  1238.  
  1239. Name:       emstotal
  1240. Purpose:    returns the total number of EMS pages (16K blocks) on the system
  1241. Prototype:  unsigned emstotal(void);
  1242. Header:     tcxlems.h
  1243. Inputs:     none
  1244. Return:     the total number of EMS pages on the system or a zero if an error
  1245.             occurred
  1246. Also see:   emsfree expmem
  1247. Example:
  1248.             printf("You have %d pages of EMS memory\n",emstotal());
  1249.  
  1250.  
  1251. Name:       emsver
  1252. Purpose:    returns the current EMS version
  1253. Prototype:  char *emsver(void);
  1254. Header:     tcxlems.h
  1255. Inputs:     none
  1256. Return:     the address of the static string containing the EMS version number
  1257.  
  1258.  
  1259.                                       21   
  1260.             or NULL if error
  1261. Example:
  1262.             printf("Your EMS version is %s\n",emsver());
  1263.  
  1264.  
  1265. Name:       emswrite
  1266. Purpose:    writes bytes to an EMS page(s), emsalloc() and emsmap() must be
  1267.             called prior to this function.  The source segment will be the
  1268.             program's DATA segment and the destination segment will be the
  1269.             EMS current EMS page frame address.
  1270. Prototype:  int emswrite(void *src,unsigned emsofs,unsigned numbytes);
  1271. Header:     tcxlems.h
  1272. Inputs:     src      - address of where to write bytes from
  1273.             emsofs   - offset from EMS page frame base address of where to write
  1274.                        bytes to
  1275.             numbytes - number of bytes to write
  1276. Return:     a zero if no error, otherwise an error
  1277. Also see:   emsframe emsmap emsread
  1278. Example:
  1279.             if(!emswrite(buf,0x100,64)) {
  1280.                 printf("Failed to write 64 bytes to EMS memory\n");
  1281.                 exit(1);
  1282.             }
  1283.  
  1284.  
  1285. Name:       expmem
  1286. Purpose:    determines the amount (if any) of expanded memory on the system
  1287. Prototype:  unsigned expmem(void);
  1288. Header:     tcxldef.h tcxlems.h
  1289. Inputs:     none
  1290. Return:     the amount of expanded memory in Kilobytes
  1291. Also see:   emsexist extmem
  1292. Example:
  1293.             printf("Amt of expanded memory = %dK\n",expmem());
  1294.  
  1295.  
  1296. Name:       extmem
  1297. Purpose:    determines the amount of extended memory on an AT machine
  1298. Prototype:  unsigned extmem(void);
  1299. Header:     tcxldef.h
  1300. Inputs:     none
  1301. Return:     the amount of extended memory in Kilobytes
  1302. Also see:   expmem
  1303. Example:
  1304.             printf("Amt of extended memory = %dK\n",extmem());
  1305.  
  1306.  
  1307. Name:       fcmpdatm
  1308. Purpose:    compares the dates and times of 2 files
  1309. Prototype:  int fcmpdatm(char *fname1,char *fname2);
  1310. Header:     tcxldsk.h
  1311. Inputs:     fname1  - address of string containing filename1
  1312.             fname2  - address of string containing filename2
  1313. Return:     -1 if less than or equal to, 0 if error, 1 if greater than
  1314. Also see:   fexist
  1315. Example:
  1316.             int i;
  1317.  
  1318.  
  1319.                                       22   
  1320.             i=fcmpdatm("C:FILE1.EXT","A:FILE1.EXT");
  1321.             if(i>0) printf("Backup copy of file needs refreshing\n");
  1322.  
  1323.  
  1324. Name:       fexist
  1325. Purpose:    determines if a disk file exists
  1326. Prototype:  int fexist(char *fname);
  1327. Header:     tcxldsk.h
  1328. Inputs:     fname   - the address of string containing file name to check,
  1329.                       wildcards are allowed in the file name
  1330. Return:     a 0 if file doesn't exist, a 1 if it does
  1331. Also see:   fcmpdatm
  1332. Example:
  1333.             int i;
  1334.             i=fexist("\\COMMAND.COM");
  1335.             printf("\\COMMAND.COM does %sexist\n",i?"":"not ");
  1336.  
  1337.  
  1338. Name:       fhide
  1339. Purpose:    hides a disk file
  1340. Prototype:  int fhide(char *filename);
  1341. Header:     tcxldsk.h
  1342. Inputs:     filename    - address of string containing file name
  1343. Return:     a zero if an error occurred
  1344. Example:
  1345.             if(!fhide("MYFILE.EXT")) {
  1346.                 printf("Could not hide file\n");
  1347.                 exit(1);
  1348.             }
  1349.  
  1350.  
  1351. Name:       fill
  1352. Purpose:    fills in a region of the screen with specified character/attribute
  1353. Prototype:  void fill(int srow,int scol,int erow,int ecol,int ch,int atr);
  1354. Header:     tcxlvid.h
  1355. Inputs:     srow    - starting row upper left corner
  1356.             scol    - starting column upper left corner
  1357.             erow    - ending row lower left corner
  1358.             ecol    - ending column lower left corner
  1359.             ch      - character to fill with
  1360.             atr     - attribute of character
  1361. Return:     none
  1362. Also see:   attrib filld
  1363. Example:
  1364.             box(1,1,10,10,3,LMAGENTA|_CYAN);
  1365.             fill(2,2,9,9,' ',WHITE|_RED);
  1366.  
  1367.  
  1368. Name:       filld
  1369. Purpose:    fills in a region of the screen with specified character/attribute
  1370.             by writing directly to the screen (no BIOS calls)
  1371. Prototype:  void filld(int srow,int scol,int erow,int ecol,int ch,int atr);
  1372. Header:     tcxlvid.h
  1373. Inputs:     srow    - starting row upper left corner
  1374.             scol    - starting column upper left corner
  1375.             erow    - ending row lower left corner
  1376.             ecol    - ending column lower left corner
  1377.  
  1378.  
  1379.                                       23   
  1380.             ch      - character to fill with
  1381.             atr     - attribute of character
  1382. Return:     none
  1383. Also see:   attrib fill videoinit
  1384. Example:
  1385.             boxd(1,1,10,10,3,LMAGENTA|_CYAN);
  1386.             filld(2,2,9,9,' ',WHITE|_RED);
  1387.  
  1388.  
  1389. Name:       gameport
  1390. Purpose:    determines if a game port is installed
  1391. Prototype:  int gameport(int equip);
  1392. Header:     tcxldef.h
  1393. Inputs:     equip   - the result from the biosequip() function
  1394. Return:     a 1 if a game port is installed
  1395. Also see:   mathchip numflop numpar numser
  1396. Example:
  1397.             int i;
  1398.             i=biosequip();
  1399.             printf("Game port is %sinstalled\n",gameport(i)?"":"not ");
  1400.  
  1401.  
  1402. Name:       getchf
  1403. Purpose:    gets a character from the keyboard from a list of valid
  1404.             characters, provides Escape checking
  1405. Prototype:  int getchf(char *valid);
  1406. Header:     tcxlkey.h
  1407. Inputs:     valid   - address of list of valid characters
  1408. Return:     the character pressed or 0 if the Escape key was pressed
  1409. Also see:   getxch waitkey
  1410. Example:
  1411.             char ch;
  1412.             printf("Are you sure?  ");
  1413.             ch=getchf("YyNn");
  1414.             if(ch!='Y'&&ch!='y') {
  1415.                 exit(0);
  1416.             }
  1417.  
  1418.  
  1419. Name:       getktot
  1420. Purpose:    gets the total disk space in kilobytes
  1421. Prototype:  unsigned getktot(int drive);
  1422. Header:     tcxldsk.h
  1423. Inputs:     drive   - the drive to check (3 = C:, 4 = D:, etc.)
  1424. Return:     size of the specified disk in kilobytes, -1 if error
  1425. Also see:   getvol
  1426. Example:
  1427.             printf("drive C: contains %u kilobytes\n",getktot(3));
  1428.  
  1429.  
  1430. Name:       getns
  1431. Purpose:    inputs a string of specified length from the keyboard, provides
  1432.             Escape checking
  1433. Prototype:  int getns(char *str,int max);
  1434. Header:     tcxlkey.h
  1435. Inputs:     str     - address of allocated space to receive input string
  1436.             max     - maximum length of the input string
  1437.  
  1438.  
  1439.                                       24   
  1440. Return:     a 1 if the <Esc> key was pressed
  1441. Also see:   inputsf prompts
  1442. Example:
  1443.             char age[2];
  1444.             printf("Enter your age:  ");
  1445.             if(getns(age,2)) {
  1446.                 printf("Escape was pressed\n");
  1447.                 exit(0);
  1448.             }
  1449.             printf("Your age is:  %s\n",age);
  1450.  
  1451.  
  1452. Name:       getvol
  1453. Purpose:    gets the volume label from a disk drive
  1454. Prototype:  char *getvol(char drive);
  1455. Header:     tcxldsk.h
  1456. Inputs:     drive   - drive letter
  1457. Return:     address of a static string containing the volume label or a zero if
  1458.             the disk has no volume label
  1459. Also see:   getktot
  1460. Example:
  1461.             printf("The volume label on drive C is:  %s\n",getvol('C'));
  1462.  
  1463.  
  1464. Name:       getxch
  1465. Purpose:    gets a key (ASCII code/extended ASCII code) from the keyboard
  1466. Prototype:  void getxch(int *ch,int *xch);
  1467. Header:     tcxlkey.h
  1468. Inputs:     ch      - the address of where to store input key's ASCII code
  1469.             xch     - the address of where to store input key's extended ASCII
  1470.                       code
  1471. Return:     none
  1472. Also see:   getchf
  1473. Example:
  1474.             int ch,xch;
  1475.             printf("Press a key:  ");
  1476.             getxch(&ch,&xch);
  1477.             printf("\nch = %c, ASCII code = %d, extended  = %d\n",ch,ch,xch);
  1478.  
  1479.  
  1480. Name:       gotoxy_
  1481. Purpose:    sets cursor coordinates on the screen
  1482. Prototype:  void gotoxy_(int row,int col);
  1483. Header:     tcxlvid.h
  1484. Inputs:     row     - cursor row (Y coordinate)
  1485.             col     - cursor column (X coordinate)
  1486. Return:     none
  1487. Also see:   readcur
  1488. Example:
  1489.             gotoxy_(20,30);
  1490.             printf("We are at row 20, column 30\n");
  1491.  
  1492.  
  1493. Name:       home
  1494. Purpose:    homes the cursor
  1495. Prototype:  void home(void);
  1496. Header:     tcxlvid.h
  1497.  
  1498.  
  1499.                                       25   
  1500. Inputs:     none
  1501. Return:     none
  1502. Also see:   clrscrn gotoxy_
  1503. Example:
  1504.             home();
  1505.             printf("We are at row 0, column 0\n");
  1506.  
  1507.  
  1508. Name:       inputsf
  1509. Purpose:    inputs a formatted string from the keyboard
  1510. Prototype:  int inputsf(char *str,char *fmt);
  1511. Header:     tcxlkey.h
  1512. Inputs:     str     - address of the allocated space to receive string
  1513.             fmt     - address of the format string, see section on using format
  1514.                       strings
  1515. Return:     a 0 if no error, a 1 if Escape, a 2 if invalid format string
  1516. Also see:   getns prompts
  1517. Example:
  1518.             char str[255];
  1519.             inputsf(str,!RE!'Enter phone number:  ('###') '###'-'####");
  1520.             printf("\nYour phone number is:  %s\n",str);
  1521.             inputsf(str,!EM!'Enter your name:  'AAAAAAAAAAAAAAAA");
  1522.             printf("\nYour name is:  %s\n",str);
  1523.  
  1524.  
  1525. Name:       kbstat
  1526. Purpose:    returns the status of the keyboard control keys
  1527. Prototype:  int kbstat(void);
  1528. Header:     tcxlkey.h
  1529. Inputs:     none
  1530. Return:     status word of the keyboard flag
  1531. Also see:   capsoff capson numoff numon
  1532. Example:
  1533.             if(kbstat()&CTRL) printf("The <Ctrl> key is now being pressed\n");
  1534.  
  1535.  
  1536. Name:       lcrlf
  1537. Purpose:    prints a carriage return and line feed on the printer
  1538. Prototype:  void lcrlf(void);
  1539. Header:     tcxlprn.h
  1540. Inputs:     none
  1541. Return:     none
  1542. Also see:   lprintc
  1543. Example:
  1544.             lprints("Hello, world");
  1545.             lcrlf();
  1546.             lprintc(FF);
  1547.  
  1548.  
  1549. Name:       lprintc
  1550. Purpose:    prints a character on the printer
  1551. Prototype:  void lprintc(int ch);
  1552. Header:     tcxlprn.h
  1553. Inputs:     ch  - the character to print
  1554. Return:     none
  1555. Also see:   lcrlf lprintf
  1556. Example:
  1557.  
  1558.  
  1559.                                       26   
  1560.             lprints("Hello, world\n");
  1561.             lprintc(FF);
  1562.  
  1563.  
  1564. Name:       lprintf
  1565. Purpose:    sends formatted output to the printer, works like printf()
  1566. Prototype:  int lprintf(const char *format,...);
  1567. Header:     tcxlprn.h
  1568. Inputs:     format  - format string, refer to Turbo C manual under printf()
  1569.             ...     - any additional arguments
  1570. Return:     a zero if no error, otherwise a memory allocation error
  1571. Also see:   lprintc lprintns lprints
  1572. Example:
  1573.             char ch='X';
  1574.             int i=327;
  1575.             char *str="Hello";
  1576.             lprintf("%s %c %d\n",str,ch,i);
  1577.  
  1578.  
  1579. Name:       lprintns
  1580. Purpose:    prints a string on the printer, formatting width
  1581. Prototype:  void lprintns(char *str,int width);
  1582. Header:     tcxlprn.h
  1583. Inputs:     str     - the address of the string to print
  1584.             width   - width to print string, uses padding or truncating
  1585. Return:     none
  1586. Also see:   lprintf lprints lprintsu
  1587. Example:
  1588.             lprintns("Hello, world",5);
  1589.             lcrlf();
  1590.             lprintc(FF);
  1591.  
  1592.  
  1593. Name:       lprints
  1594. Purpose:    prints a string on the printer
  1595. Prototype:  void lprints(char *str);
  1596. Header:     tcxlprn.h
  1597. Inputs:     str     - the address of the string to print
  1598. Return:     none
  1599. Also see:   lprintf lprintns lprintsu
  1600. Example:
  1601.             lprints("Hello, world\n");
  1602.             lprintc(FF);
  1603.  
  1604.  
  1605. Name:       lprintsb
  1606. Purpose:    prints a bold-faced string on the printer
  1607. Prototype:  void lprintsb(char *str);
  1608. Header:     tcxlprn.h
  1609. Inputs:     str     - the address of the string to print
  1610. Return:     none
  1611. Also see:   lprints lprintsu
  1612. Example:
  1613.             lprintsb("Hello, world\n");
  1614.             lprintc(FF);
  1615.  
  1616.  
  1617.  
  1618.  
  1619.                                       27   
  1620. Name:       lprintsu
  1621. Purpose:    prints an underlined string on the printer
  1622. Prototype:  void lprintsu(char *str);
  1623. Header:     tcxlprn.h
  1624. Inputs:     str     - the address of the string to print
  1625. Return:     none
  1626. Also see:   lprints lprintsb
  1627. Example:
  1628.             lprintsu("Hello, world\n");
  1629.             lprintc(FF);
  1630.  
  1631.  
  1632. Name:       machid
  1633. Purpose:    returns the value of the machine ROM ID byte
  1634. Prototype:  int machid(void);
  1635. Header:     tcxldef.h
  1636. Inputs:     none
  1637. Return:     the value of the machine ROM ID byte
  1638. Also see:   biosver
  1639. Example:
  1640.             if(machid()==IBMPCAT) printf("You have an IBM PC/AT\n");
  1641.  
  1642.  
  1643. Name:       mathchip
  1644. Purpose:    determines if a math coprocessor is installed
  1645. Prototype:  int mathchip(int equip);
  1646. Header:     tcxldef.h
  1647. Inputs:     equip   - the result from the biosequip() function
  1648. Return:     a 1 if a math coprocessor is installed
  1649. Also see:   gameport numflop numpar numser
  1650. Example:
  1651.             int i;
  1652.             i=biosequip();
  1653.             printf("Math coprocessor is %sinstalled\n",mathchip(i)?"":"not ");
  1654.  
  1655.  
  1656. Name:       mode
  1657. Purpose:    sets the video mode
  1658. Prototype:  void mode(int mode_code);
  1659. Header:     tcxlvid.h
  1660. Inputs:     mode_code   - mode code number
  1661. Return:     none
  1662. Also see:   setlines vidtype
  1663. Example:
  1664.             mode(4);
  1665.             printf("We are now in CGA graphics mode\n");
  1666.  
  1667.  
  1668. Name:       msbpress
  1669. Purpose:    gets info about specific button presses of mouse
  1670. Prototype:  void msbpress(int button,int *bstat,int *bcount,int *x,int *y);
  1671. Header:     tcxlmou.h
  1672. Inputs:     button  - button to check, 0 = left button, 1 = right button
  1673.             bstat   - address to receive button status (0 = not being pressed,
  1674.                       1 = currently being pressed)
  1675.             bcount  - address to receive number of times pressed since last
  1676.                       call
  1677.  
  1678.  
  1679.                                       28   
  1680.             x       - address to receive X pixel coordinate at time of press
  1681.             y       - address to receive Y pixel coordinate at time of press
  1682. Return:     none
  1683. Also see:   msbreles msstatus
  1684. Example:
  1685.             int bstat,int bcount,int x,int y;
  1686.             msbpres(0,&bstat,&bcount,&x,&y);
  1687.             printf("bstat = %d, bcount = %d, x = %d, y = %d\n",bstat,bcount,
  1688.                 x,y);
  1689.  
  1690.  
  1691. Name:       msbreles
  1692. Purpose:    gets info about specific button releases of mouse
  1693. Prototype:  void msbreles(int button,int *bstat,int *bcount,int *x,int *y);
  1694. Header:     tcxlmou.h
  1695. Inputs:     button  - button to check, 0 = left button, 1 = right button
  1696.             bstat   - address to receive button status (0 = not being pressed,
  1697.                       1 = currently being pressed)
  1698.             bcount  - address to receive number of times released since last
  1699.                       call
  1700.             x       - address to receive X pixel coordinate at time of release
  1701.             y       - address to receive Y pixel coordinate at time of release
  1702. Return:     none
  1703. Also see:   msbpress msstatus
  1704. Example:
  1705.             int bstat,int bcount,int x,int y;
  1706.             msbreles(0,&bstat,&bcount,&x,&y);
  1707.             printf("bstat = %d, bcount = %d, x = %d, y = %d\n",bstat,bcount,
  1708.                 x,y);
  1709.  
  1710.  
  1711. Name:       mscursor
  1712. Purpose:    sets the mouse cursor mode
  1713. Prototype:  void mscursor(int curtype,int smask,int cmask);
  1714. Header:     tcxlmou.h
  1715. Inputs:     curtype     - cursor type, 0 = software, 1 = hardware
  1716.             smask       - screen mask (SW) or start scan line (HW), see section
  1717.                           on using mouse functions for a description of mask
  1718.             cmask       - cursor mask (SW) or stop scan line (HW), see section
  1719.                           on using mouse functions for a description of mask
  1720. Return:     none
  1721. Also see:   msshowcur
  1722.  
  1723.  
  1724. Name:       msgotoxy
  1725. Purpose:    sets the mouse coordinates
  1726. Prototype:  void msgotoxy(int x,int y);
  1727. Header:     tcxlmou.h
  1728. Inputs:     x   -   X pixel coordinate
  1729.             y   -   Y pixel coordinate
  1730. Return:     none
  1731. Also see:   msstatus
  1732. Example:
  1733.             msgotoxy(20*8,10*8);  /* sets mouse cursor at row 10, column 20 */
  1734.  
  1735.  
  1736. Name:       mshbounds
  1737.  
  1738.  
  1739.                                       29   
  1740. Purpose:    sets the mouse horizontal bounds
  1741. Prototype:  void mshbounds(int left,int right);
  1742. Header:     tcxlmou.h
  1743. Inputs:     left    - left pixel boundry
  1744.             right   - right pixel boundry
  1745. Return:     none
  1746. Also see:   msvbounds
  1747. Example:
  1748.                          /* limits mouse movement between columns 40 and 60 */
  1749.             mshbounds(40*8,60*8);
  1750.  
  1751.  
  1752. Name:       mshidecur
  1753. Purpose:    hides the mouse cursor
  1754. Prototype:  void mshidecur(void);
  1755. Header:     tcxlmou.h
  1756. Inputs:     none
  1757. Return:     none
  1758. Also see:   msshowcur
  1759. Example:
  1760.             msshowcur();        /*  now you see mouse cursor  */
  1761.             mshidecur();        /*  now you don't             */
  1762.  
  1763.  
  1764. Name:       msinit
  1765. Purpose:    determines if mouse is present.  If so, initializes mouse.  See
  1766.             section on how to use TCXL's mouse functions for details.
  1767. Prototype:  int msinit(void);
  1768. Header:     tcxlmou.h
  1769. Inputs:     none
  1770. Return:     a 0 if mouse is not present
  1771. Example:
  1772.             if(msinit()) {
  1773.                 printf("Mouse initialized!\n");
  1774.             }
  1775.             else {
  1776.                 printf("Mouse does not exist\n");
  1777.             }
  1778.  
  1779.  
  1780. Name:       msmotion
  1781. Purpose:    gets information about the movement of mouse
  1782. Prototype:  void msmotion(int *xcount,int *ycount);
  1783. Header:     tcxlmou.h
  1784. Inputs:     xcount   - address to receive amount of X movement in pixels -/+
  1785.             ycount   - address to receive amount of Y movement in pixels -/+
  1786. Return:     none
  1787. Example:
  1788.             int xcount,ycount;
  1789.             msinit();
  1790.             msmotion(&xcount,&ycount);
  1791.             printf("Move mouse, then press a key\n");
  1792.             waitkey();
  1793.             msmotion(&xcount,&ycount);
  1794.             if(xcount<0) printf("mouse moved left\n");
  1795.             if(xcount>0) printf("mouse moved right\n");
  1796.             if(ycount<0) printf("mouse moved up\n");
  1797.  
  1798.  
  1799.                                       30   
  1800.             if(ycount>0) printf("mouse moved down\n");
  1801.  
  1802.  
  1803. Name:       msshowcur
  1804. Purpose:    reveals the mouse cursor
  1805. Prototype:  void msshowcur(void);
  1806. Header:     tcxlmou.h
  1807. Inputs:     none
  1808. Return:     none
  1809. Also see:   mshidecur
  1810. Example:
  1811.             msshowcur();        /*  now you see mouse cursor  */
  1812.             mshidecur();        /*  now you don't             */
  1813.  
  1814.  
  1815. Name:       msspeed
  1816. Purpose:    adjusts mouse speed by changing its sensitivity
  1817. Prototype:  void msspeed(int xratio,int yratio);
  1818. Header:     tcxlmou.h
  1819. Inputs:     xratio      - horizontal speed (higher numbers are slower)
  1820.             yratio      - vertical speed (higher numbers are slower)
  1821. Return:     none
  1822. Example:
  1823.             msinit();
  1824.             msshowcur();
  1825.             printf("move mouse around, then press a key\n");
  1826.             waitkey();
  1827.             msspeed(15,15);
  1828.             printf("now see how mouse moves\n");
  1829.             waitkey();
  1830.  
  1831.  
  1832. Name:       msstatus
  1833. Purpose:    returns the mouse status
  1834. Prototype:  void msstatus(int *bstat,int *x,int *y);
  1835. Header:     tcxlmou.h
  1836. Inputs:     bstat   - address to receive button status (0 = not pressed, 1 =
  1837.                       pressed)
  1838.             x       - address to receive current X pixel coordinate
  1839.             y       - address to receive current Y pixel coordinate
  1840. Return:     none
  1841. Example:
  1842.             int bstat,x,y;
  1843.             msstatus(&bstat,&x,&y);
  1844.             printf("bstat = %d, x = %d, y = %d\n",bstat,x,y);
  1845.  
  1846.  
  1847. Name:       msvbounds
  1848. Purpose:    sets the mouse vertical bounds
  1849. Header:     tcxlmou.h
  1850. Prototype:  void msvbounds(int top,int bottom);
  1851. Inputs:     top     - top pixel boundry
  1852.             bottom  - bottom pixel boundry
  1853. Return:     none
  1854. Also see:   mshbounds
  1855. Example:
  1856.                         /*  limits mouse movement between rows 10 and 20  */
  1857.  
  1858.  
  1859.                                       31   
  1860.             msvbounds(10*8,20*8);
  1861.  
  1862.  
  1863. Name:       numflop
  1864. Purpose:    returns the number of floppy disk drives installed
  1865. Prototype:  int numflop(int equip);
  1866. Header:     tcxlmou.h
  1867. Header:     tcxldef.h
  1868. Inputs:     equip   - the result from the biosequip() function
  1869. Return:     the number of floppy disk drives installed
  1870. Also see:   gameport mathchip numpar numser
  1871. Example:
  1872.             int i;
  1873.             i=biosequip();
  1874.             printf("Number of floppy disk drives = %d\n",numflop(i));
  1875.  
  1876.  
  1877. Name:       numoff
  1878. Purpose:    toggles the NumLock key off
  1879. Prototype:  void numoff(void);
  1880. Header:     tcxlkey.h
  1881. Inputs:     none
  1882. Return:     none
  1883. Also see:   capsoff kbstat numon
  1884. Example:
  1885.             numoff();
  1886.  
  1887.  
  1888. Name:       numon
  1889. Purpose:    toggles the NumLock key on
  1890. Prototype:  void numon(void);
  1891. Header:     tcxlkey.h
  1892. Inputs:     none
  1893. Return:     none
  1894. Also see:   capson kbstat numoff
  1895. Example:
  1896.             numon();
  1897.  
  1898.  
  1899. Name:       numpar
  1900. Purpose:    determines the number of parallel ports
  1901. Prototype:  int numpar(int equip);
  1902. Header:     tcxldef.h
  1903. Inputs:     equip   - the result from the biosequip() function
  1904. Return:     the number of parallel ports installed
  1905. Also see:   gameport mathchip numflop numser
  1906. Example:
  1907.             int i;
  1908.             i=biosequip();
  1909.             printf("Number of parallel ports = %d\n",numpar(i));
  1910.  
  1911.  
  1912. Name:       numser
  1913. Purpose:    determines the number of serial ports installed
  1914. Prototype:  int numser(int equip);
  1915. Header:     tcxldef.h
  1916. Inputs:     equip   - the result from the biosequip() function
  1917.  
  1918.  
  1919.                                       32   
  1920. Return:     the number of serial ports installed
  1921. Also see:   gameport mathchip numflop numpar
  1922. Example:
  1923.             int i;
  1924.             i=biosequip();
  1925.             printf("Number of serial ports = %d\n",numser(i));
  1926.  
  1927.  
  1928. Name:       printc
  1929. Purpose:    prints a character to the screen at a specified location and
  1930.             attribute
  1931. Prototype:  void printc(int row,int col,int attr,int ch,int count);
  1932. Header:     tcxlvid.h
  1933. Inputs:     row     - row
  1934.             col     - column
  1935.             attr    - attribute of character
  1936.             ch      - character to print
  1937.             count   - number of times to print character
  1938. Return:     none
  1939. Also see:   attrib printcd
  1940. Example:
  1941.             printc(18,60,LGREEN|BLINK,'Z',5);
  1942.  
  1943.  
  1944. Name:       printcd
  1945. Purpose:    prints a character directly to the screen at a specified
  1946.             location and attribute (no BIOS calls)
  1947. Prototype:  void printcd(int row,int col,int attr,int ch);
  1948. Header:     tcxlvid.h
  1949. Inputs:     row     - row
  1950.             col     - column
  1951.             attr    - attribute of character
  1952.             ch      - character to print
  1953. Return:     none
  1954. Also see:   attrib printc videoinit
  1955. Example:
  1956.             printcd(18,60,LGREEN|BLINK,'Z');
  1957.  
  1958.  
  1959. Name:       prints
  1960. Purpose:    displays a string on the screen at a specified location
  1961.             and attribute
  1962. Prototype:  void prints(int row,int col,int attr,char *str);
  1963. Header:     tcxlvid.h
  1964. Inputs:     row     - cursor row
  1965.             col     - cursor column
  1966.             attr    - character attribute
  1967.             str     - address of string to display
  1968. Return:     none
  1969. Also see:   attrib printsd
  1970. Example:
  1971.             prints(20,10,LRED|_LGREY,"Hello, world");
  1972.  
  1973.  
  1974. Name:       printsd
  1975. Purpose:    displays a string at a specified location in a specified
  1976.             attribute directly on the screen (no BIOS calls)
  1977.  
  1978.  
  1979.                                       33   
  1980. Prototype:  void printsd(int row,int col,int attr,char *str);
  1981. Header:     tcxlvid.h
  1982. Inputs:     row     - cursor row
  1983.             col     - cursor column
  1984.             attr    - character attribute
  1985.             str     - address of string to display
  1986. Return:     none
  1987. Also see:   attrib prints videoinit
  1988. Example:
  1989.             printsd(20,10,LRED|_LGREY,"Hello, world");
  1990.  
  1991.  
  1992. Name:       prompts
  1993. Purpose:    prompts for a string and accepts keyboard input
  1994. Prototype:  void prompts(char *prompt,char *str);
  1995. Header:     tcxlkey.h
  1996. Inputs:     prompt  - address of string containing prompt
  1997.             str     - address of where to place input string
  1998. Return:     none
  1999. Also see:   getns inputsf
  2000. Example:
  2001.             char name[30];
  2002.             prompts("Enter your name:  ",name);
  2003.  
  2004.  
  2005. Name:       readchat
  2006. Purpose:    reads the character and attribute under the cursor
  2007. Prototype:  int readchat(void);
  2008. Header:     tcxlvid.h
  2009. Inputs:     none
  2010. Return:     integer containing character in low byte and attribute in high byte
  2011. Also see:   revattr setattr
  2012. Example:
  2013.             int i;
  2014.             prints(0,0,LGREEN|_BLUE,"Hello, world");
  2015.             gotoxy_(0,7);
  2016.             i=readchat();
  2017.             gotoxy_(1,0);
  2018.             printf("character is %c and attribute is %d\n",i,(i>>8));
  2019.  
  2020.  
  2021. Name:       readcur
  2022. Purpose:    reads the current cursor location
  2023. Prototype:  void readcur(int *row,int *col);
  2024. Header:     tcxlvid.h
  2025. Inputs:     row     - address of location to receive cursor row
  2026.             col     - address of location to receive cursor column
  2027. Return:     none
  2028. Also see:   gotoxy_
  2029. Example:
  2030.             int row,col;
  2031.             readcur(&row,&col);
  2032.             prints(0,0,LCYAN|BLINK,"Hello, world");
  2033.             prints(row,col,LWHITE,"Hello,world");
  2034.  
  2035.  
  2036. Name:       revattr
  2037.  
  2038.  
  2039.                                       34   
  2040. Purpose:    reverses the attribute of the character under the current cursor
  2041.             location
  2042. Prototype:  void revattr(int count);
  2043. Header:     tcxlvid.h
  2044. Inputs:     count   - the number of characters to reverse attribute of
  2045. Return:     none
  2046. Also see:   readchat setattr
  2047. Example:
  2048.             prints(0,0,LCYAN|_BLUE,"Hello, world");
  2049.             gotoxy_(0,0);
  2050.             revattr(5);
  2051.  
  2052.  
  2053. Name:       scrndump
  2054. Purpose:    dumps the current screen to the printer
  2055. Prototype:  void scrndump(void);
  2056. Header:     tcxlprn.h
  2057. Inputs:     none
  2058. Return:     none
  2059. Also see:   scrntodisk ssave videoinit
  2060. Example:
  2061.             printf("Turn printer on and press a key to continue....");
  2062.             waitkey();
  2063.             scrndump();
  2064.  
  2065.  
  2066. Name:       scrntodisk
  2067. Purpose:    copies the current screen to a disk file
  2068. Prototype:  int scrntodisk(char *fname);
  2069. Header:     tcxldsk.h  tcxlvid.h
  2070. Inputs:     fname   - address of the string containing file to write to
  2071. Return:     a zero if no error
  2072. Also see:   disktoscrn scrndump ssave wintodisk
  2073. Example:
  2074.             if(scrntodisk("SCREEN.DAT")) {
  2075.                 printf("Error creating file\n");
  2076.                 exit(1);
  2077.             }
  2078.  
  2079.  
  2080. Name:       setattr
  2081. Purpose:    sets the attribute of the character under the current cursor
  2082.             location
  2083. Prototype:  void setattr(int attr,int count);
  2084. Header:     tcxlvid.h
  2085. Inputs:     attr    - attribute to set character
  2086.             count   - the number of characters to set the attribute of
  2087. Return:     none
  2088. Also see:   attrib readchat revattr
  2089. Example:
  2090.             prints(0,0,LCYAN|_BLUE,"Hello, world");
  2091.             gotoxy_(0,0);
  2092.             setattr(LRED|BLINK,5);
  2093.  
  2094.  
  2095. Name:       setcursz
  2096. Purpose:    sets the cursor size
  2097.  
  2098.  
  2099.                                       35   
  2100. Prototype:  void setcursz(int sline,int eline);
  2101. Header:     tcxlvid.h
  2102. Inputs:     sline   - start line of cursor (32 for no cursor)
  2103.             eline   - end line of cursor
  2104. Return:     none
  2105. Example:
  2106.             setcursz(1,7);
  2107.             printf("The cursor is now large\n");
  2108.  
  2109.  
  2110. Name:       setlines
  2111. Purpose:    sets the number of lines on the display
  2112. Prototype:  int setlines(int numlines);
  2113. Header:     tcxlvid.h
  2114. Inputs:     numlines    - the number of lines to set the display to, valid
  2115.                           numbers are 25, 43 for EGA, and 50 for VGA.
  2116. Return:     zero if no error
  2117. Also see:   mode vidtype
  2118. Example:
  2119.             if(setlines(43)) {
  2120.                 printf("You need an EGA monitor for 43-line mode\n");
  2121.             }
  2122.             else {
  2123.                 printf("You are now in EGA 43-line mode\n");
  2124.             }
  2125.  
  2126.  
  2127. Name:       sound_
  2128. Purpose:    sounds a tone of specified pitch and duration
  2129. Prototype:  void sound_(unsigned pitch,unsigned duration);
  2130. Header:     tcxldef.h
  2131. Inputs:     pitch       - pitch of tone (0-65535)
  2132.             duration    - duration of tone (0-65535) ie. 18 = 1 second
  2133. Return:     none
  2134. Also see:   beep
  2135. Example:
  2136.             sound_(255,3);
  2137.  
  2138.  
  2139. Name:       spc
  2140. Purpose:    displays a specified number of spaces to the screen
  2141. Prototype:  void spc(int num);
  2142. Header:     tcxlvid.h
  2143. Inputs:     num     - number of spaces to display
  2144. Return:     none
  2145. Example:
  2146.             prints(15,50,7,"0123456789");
  2147.             gotoxy_(15,53);
  2148.             spc(3);
  2149.  
  2150.  
  2151. Name:       srestore
  2152. Purpose:    restores a previously saved screen
  2153. Prototype:  void srestore(int *sbuf);
  2154. Header:     tcxlvid.h
  2155. Inputs:     sbuf    - address of previously saved screen buffer
  2156. Return:     none
  2157.  
  2158.  
  2159.                                       36   
  2160. Also see:   ssave videoinit wrestore
  2161. Example:
  2162.             int *sbuf;
  2163.             sbuf=ssave();
  2164.             clrscrn();
  2165.             srestore(sbuf);
  2166.  
  2167.  
  2168. Name:       ssave
  2169. Purpose:    saves the current screen to a buffer
  2170. Prototype:  int *ssave(void);
  2171. Header:     tcxlvid.h
  2172. Inputs:     none
  2173. Return:     address of newly created screen buffer or 0 if allocation error
  2174. Also see:   scrndump scrntodisk srestore videoinit wsave
  2175. Example:
  2176.             int *sbuf;
  2177.             sbuf=ssave();
  2178.             clrscrn();
  2179.             srestore(sbuf);
  2180.  
  2181.  
  2182. Name:       strbmatch
  2183. Purpose:    returns the best match of a string in an array of strings
  2184. Prototype:  char *strbmatch(char *str,char *strarr[]);
  2185. Header:     tcxlstr.h
  2186. Inputs:     str     - address of string to match
  2187.             strarr  - address of array of string pointers, the last string in
  2188.                       the array must be empty
  2189. Return:     address of the string in the array that best matched the given
  2190.             string
  2191. Also see:   strmatch
  2192. Example:
  2193.             char *strarr[4]= { "Hello","Computer","World","" };
  2194.             char *str="help";
  2195.             printf("best match is:  %s\n",strbmatch(str,strarr);
  2196.  
  2197.  
  2198. Name:       strchg
  2199. Purpose:    finds all letters in a string matching one character and
  2200.             replaces them with another
  2201. Prototype:  char *strchg(char *str,int oldch,int newch);
  2202. Header:     tcxlstr.h
  2203. Inputs:     str     - address of string to search
  2204.             oldch   - character to search for
  2205.             newch   - character to replace with
  2206. Return:     the address of the modified string or a NULL if no matches found
  2207. Also see:   strichg
  2208. Example:
  2209.             char *str="Hello there";
  2210.             printf("Before:  %s\n",str);
  2211.             strchg(str,'h','*');
  2212.             printf("After:  %s\n",str);
  2213.  
  2214.  
  2215. Name:       strcode
  2216. Purpose:    encodes/decodes a string, call this function to encode a string,
  2217.  
  2218.  
  2219.                                       37   
  2220.             then call again using the same key to decode, when reading or
  2221.             writing from a disk file, be sure to open the file in binary mode
  2222. Prototype:  char *strcode(char *str,int key);
  2223. Header:     tcxlstr.h
  2224. Inputs:     str  - the string to encode/decode
  2225.             key  - a key to encode the string with (1-255), to decode you must
  2226.             use the same key as when encoded
  2227. Return:     the address of the encoded/decoded string
  2228. Example:
  2229.             char *str="Hello, world";
  2230.             printf("Before:   %s\n",str);
  2231.             strcode(str,37);
  2232.             printf("Encoded:  %s\n",str);
  2233.             strcode(str,37);
  2234.             printf("Decoded:  %s\n",str);
  2235.  
  2236.  
  2237. Name:       strdel
  2238. Purpose:    deletes a substring from within a string
  2239. Prototype:  char *strdel(char *substr,char *str);
  2240. Header:     tcxlstr.h
  2241. Inputs:     substr  - address of substring to delete
  2242.             str     - address of string to delete from
  2243. Return:     a NULL if the substring was not found, or the address of the
  2244.             modified string
  2245. Also see:   stridel strinc strins strmid
  2246. Example:
  2247.             char *str="Hello, XXXXXworld";
  2248.             strdel("XXXXX",str);
  2249.             printf("%s\n",str);
  2250.  
  2251.  
  2252. Name:       strichg
  2253. Purpose:    finds all letters in a string matching one character and
  2254.             replaces them with another, ignoring case of letters
  2255. Prototype:  char *strichg(char *str,int oldch,int newch);
  2256. Header:     tcxlstr.h
  2257. Inputs:     str     - address of string to search
  2258.             oldch   - character to search for
  2259.             newch   - character to replace with
  2260. Return:     the address of the modified string or a NULL if no matches found
  2261. Also see:   strchg
  2262. Example:
  2263.             char *str="Hello there";
  2264.             printf("Before:  %s\n",str);
  2265.             strichg(str,'h','*');
  2266.             printf("After:  %s\n",str);
  2267.  
  2268.  
  2269. Name:       stridel
  2270. Purpose:    deletes a substring from within a string, ignoring case of letters
  2271. Prototype:  char *stridel(char *substr,char *str);
  2272. Header:     tcxlstr.h
  2273. Inputs:     substr  - address of substring to delete
  2274.             str     - address of string to delete from
  2275. Return:     a NULL if the substring was not found, or the address of the
  2276.             modified string
  2277.  
  2278.  
  2279.                                       38   
  2280. Also see:   strdel striinc
  2281. Example:
  2282.             char *str="Hello, XXXXXworld";
  2283.             stridel("XXXXX",str);
  2284.             printf("%s\n",str);
  2285.  
  2286.  
  2287. Name:       striinc
  2288. Purpose:    determines if one string is included in another, ignoring case of
  2289.             letters
  2290. Prototype:  char *striinc(char *str1,char *str2);
  2291. Header:     tcxlstr.h
  2292. Inputs:     str1    - address of string1
  2293.             str2    - address of string2
  2294. Return:     the address where string1 is included in string2, or a NULL if
  2295.             string1 is not included in string2
  2296. Also see:   strinc strmid
  2297. Example:
  2298.             char *str1="HeLlo WOrLd";
  2299.             char *str2="XXXXXXXHello, worldXXXXX";
  2300.             if(striinc(str1,str2)) printf("%s is included in %s\n",str1,str2);
  2301.  
  2302.  
  2303. Name:       strinc
  2304. Purpose:    determines if one string is included in another
  2305. Prototype:  char *strinc(char *str1,char *str2);
  2306. Header:     tcxlstr.h
  2307. Inputs:     str1    - address of string1
  2308.             str2    - address of string2
  2309. Return:     the address where string1 is included in string2, or a NULL if
  2310.             string1 is not included in string2
  2311. Also see:   striinc strmid
  2312. Example:
  2313.             char *str1="Hello world";
  2314.             char *str2="XXXXXXXHello, worldXXXXX";
  2315.             if(strinc(str1,str2)) printf("%s is included in %s\n",str1,str2);
  2316.  
  2317.  
  2318. Name:       strins
  2319. Purpose:    inserts one string into another
  2320. Prototype:  char *strins(char *instr,char **str,int st_pos);
  2321. Header:     tcxlstr.h
  2322. Inputs:     instr   - the address of the string to insert
  2323.             str     - the address of the address of the string to insert into
  2324.             st_pos  - the starting position for where to insert
  2325. Return:     the address of the newly allocated string, or a NULL if a memory
  2326.             allocation error occurred
  2327. Also see:   strdel strinc
  2328. Example:
  2329.             char *str="Hello!";
  2330.             printf("%s\n",str);
  2331.             strins(", world",&str,5);
  2332.             printf("%s\n",str);
  2333.             free(str);              /*  free memory when done with string  */
  2334.  
  2335.  
  2336. Name:       striocc
  2337.  
  2338.  
  2339.                                       39   
  2340. Purpose:    returns the number of occurrences of a character in a string
  2341.             ignoring the case of letters
  2342. Prototype:  int striocc(char *str,int ch);
  2343. Header:     tcxlstr.h
  2344. Inputs:     str     - address of the string to search
  2345.             ch      - the character to look for
  2346. Return:     the number of occurrences of the character in the string
  2347. Also see:   strocc
  2348. Example:
  2349.             char ch='L';
  2350.             char *str="Hello, world";
  2351.             printf("%c occurs in %s %d times\n",ch,str,striocc(str,ch));
  2352.  
  2353.  
  2354. Name:       strleft
  2355. Purpose:    takes a specified portion of a string from the left and creates
  2356.             a new string
  2357. Prototype:  char *strleft(char *str,int num_chars);
  2358. Header:     tcxlstr.h
  2359. Inputs:     str         - address of input string
  2360.             num_chars   - number of characters to copy
  2361. Return:     address of the newly created string or a NULL if a memory
  2362.             allocation error occurred
  2363. Also see:   strmid strright strtrim
  2364. Example:
  2365.             char *left;
  2366.             char *str="Hello, worldXXXX";
  2367.             left=strleft(str,12);
  2368.             printf("%s\n",left);
  2369.             free(left);             /*  free memory when done with string  */
  2370.  
  2371.  
  2372. Name:       strltrim
  2373. Purpose:    trims leading spaces off of a string
  2374. Prototype:  char *strtrim(char **str);
  2375. Header:     tcxlstr.h
  2376. Inputs:     str  - address of the address of the string to trim
  2377. Return:     address of the modified string
  2378. Also see:   strright strsetsz strtrim
  2379. Example:
  2380.             char *str="        Hello, world";
  2381.             printf("%s.\n",str);
  2382.             strltrim(&str);
  2383.             printf("%s.\n",str);
  2384.  
  2385.  
  2386. Name:       strmatch
  2387. Purpose:    compares 2 strings, returns a match score
  2388. Prototype:  int strmatch(char *str1,char *str2);
  2389. Header:     tcxlstr.h
  2390. Inputs:     str1    - address of first string
  2391.             str2    - address of second string
  2392. Return:     a match score, the higher the score, the better they match
  2393. Also see:   strbmatch
  2394. Example:
  2395.             char *str1="hello";
  2396.             char *str2="help";
  2397.  
  2398.  
  2399.                                       40   
  2400.             printf("match score = %d\n",strmatch(str1,str2);
  2401.  
  2402.  
  2403. Name:       strmid
  2404. Purpose:    takes a section from input string starting at given position
  2405.             and taking the given amount of characters creating a new string
  2406. Prototype:  char *strmid(char *str,int st_pos,int num_chars);
  2407. Header:     tcxlstr.h
  2408. Inputs:     str         - address of input string
  2409.             st_pos      - position in input string to start copying characters
  2410.                           (starting at position 0)
  2411.             num_chars   - number of characters to copy
  2412. Return:     address of the newly created string or a NULL if a memory
  2413.             allocation error occurred
  2414. Also see:   strleft strright
  2415. Example:
  2416.             char *middle;
  2417.             char *str="XXXXXHello, worldXXXX";
  2418.             middle=strmid(str,5,12);
  2419.             printf("%s\n",middle);
  2420.             free(middle);             /*  free memory when done with string  */
  2421.  
  2422.  
  2423. Name:       strocc
  2424. Purpose:    returns the number of occurrences of a character in a string
  2425. Prototype:  int strocc(char *str,int ch);
  2426. Header:     tcxlstr.h
  2427. Inputs:     str     - address of the string to search
  2428.             ch      - the character to look for
  2429. Return:     the number of occurrences of the character in the string
  2430. Also see:   striocc
  2431. Example:
  2432.             char ch='l';
  2433.             char *str="Hello, world";
  2434.             printf("%c occurs in %s %d times\n",ch,str,strocc(str,ch));
  2435.  
  2436.  
  2437. Name:       strright
  2438. Purpose:    takes a specifed portion from the right side of a string creating
  2439.             a new string
  2440. Prototype:  char *strright(char *str,int num_chars);
  2441. Header:     tcxlstr.h
  2442. Inputs:     str         - address of input string
  2443.             num_chars   - number of characters to copy
  2444. Return:     address of the newly created string or a NULL if a memory
  2445.             allocation error occurred
  2446. Also see:   strleft strltrim strmid
  2447. Example:
  2448.             char *right;
  2449.             char *str="XXXXXHello, world";
  2450.             right=strright(str,12);
  2451.             printf("%s\n",right);
  2452.             free(right);             /*  free memory when done with string  */
  2453.  
  2454.  
  2455. Name:       strrol
  2456. Purpose:    rotates a string specified number of characters left, characters
  2457.  
  2458.  
  2459.                                       41   
  2460.             wrap around
  2461. Prototype:  char *strrol(char *str,int count);
  2462. Header:     tcxlstr.h
  2463. Inputs:     str    - the address of the string to rotate
  2464.             count  - number of characters to rotate
  2465. Return:     the address of the modified string
  2466. Also see:   strror strshl
  2467. Example:
  2468.             char *str="Hello, world";
  2469.             printf("%s.\n",str);
  2470.             strrol(str,3);
  2471.             printf("%s.\n",str);
  2472.  
  2473.  
  2474. Name:       strror
  2475. Purpose:    rotates a string specified number of characters right, characters
  2476.             wrap around
  2477. Prototype:  char *strror(char *str,int count);
  2478. Header:     tcxlstr.h
  2479. Inputs:     str    - the address of the string to rotate
  2480.             count  - number of characters to rotate
  2481. Return:     the address of the modified string
  2482. Also see:   strrol strshr
  2483. Example:
  2484.             char *str="Hello, world";
  2485.             printf("%s.\n",str);
  2486.             strror(str,3);
  2487.             printf("%s.\n",str);
  2488.  
  2489.  
  2490. Name:       strsetsz
  2491. Purpose:    adjusts the length of a string by truncation or padding with
  2492.             spaces
  2493. Prototype:  char *strsetsz(char **str,int newsize);
  2494. Header:     tcxlstr.h
  2495. Inputs:     str     - address of pointer to the string
  2496.             newsize - the new length of the string
  2497. Return:     address of the new string or a NULL if a memory allocation error
  2498.             occurred
  2499. Also see:   strtrim
  2500. Example:
  2501.             char *str="Hello, world";
  2502.             strsetsz(&str,25);
  2503.             printf("%s.\n",str);
  2504.             strsetsz(&str,5);
  2505.             printf("%s.\n",str);
  2506.  
  2507.  
  2508. Name:       strshl
  2509. Purpose:    shifts a string specified number of characters left, characters
  2510.             'drop off' and spaces are added to the string
  2511. Prototype:  char *strshl(char *str,int count);
  2512. Header:     tcxlstr.h
  2513. Inputs:     str    - the address of the string to shift
  2514.             count  - number of characters to shift
  2515. Return:     the address of the modifed string
  2516. Also see:   strrol strshr
  2517.  
  2518.  
  2519.                                       42   
  2520. Example:
  2521.             char *str="Hello, world";
  2522.             printf("%s.\n",str);
  2523.             strshl(str,3);
  2524.             printf("%s.\n",str);
  2525.  
  2526.  
  2527. Name:       strshr
  2528. Purpose:    shifts a string specified number of characters right, characters
  2529.             'drop off' and spaces are added to the string
  2530. Prototype:  char *strshr(char *str,int count);
  2531. Header:     tcxlstr.h
  2532. Inputs:     str    - the address of the string to shift
  2533.             count  - number of characters to shift
  2534. Return:     the address of the modified string
  2535. Also see:   strror strshl
  2536. Example:
  2537.             char *str="Hello, world";
  2538.             printf("%s.\n",str);
  2539.             strshr(str,3);
  2540.             printf("%s.\n",str);
  2541.  
  2542.  
  2543. Name:       strtrim
  2544. Purpose:    trims trailing spaces off of a string
  2545. Prototype:  char *strtrim(char *str);
  2546. Header:     tcxlstr.h
  2547. Inputs:     str  - address of the string to trim
  2548. Return:     address of the modified string
  2549. Also see:   strleft strltrim strsetsz
  2550. Example:
  2551.             char *str="Hello, world          ";
  2552.             printf("%s.\n",str);
  2553.             strtrim(str);
  2554.             printf("%s.\n",str);
  2555.  
  2556.  
  2557. Name:       struplow
  2558. Purpose:    converts a string to mixed upper & lower case characters
  2559. Prototype:  char *struplow(char *str);
  2560. Header:     tcxlstr.h
  2561. Inputs:     str   - the address of the string to convert
  2562. Return:     the address of the modified string
  2563. Also see:   touplow
  2564. Example:
  2565.             char *str="heLlO, wOrLd";
  2566.             printf("%s.\n",str);
  2567.             struplow(str);
  2568.             printf("%s.\n",str);
  2569.  
  2570.  
  2571. Name:       tabstop
  2572. Purpose:    calculates a tab stop from given column and tab width
  2573. Prototype:  int tabstop(int col,int tabwidth);
  2574. Header:     tcxldef.h
  2575. Inputs:     col         - column
  2576.             tabwidth    - tab width
  2577.  
  2578.  
  2579.                                       43   
  2580. Return:     the next tab stop
  2581. Example:
  2582.             printf("tabstop after column 5 is %d\n",tabstop(5,8);
  2583.  
  2584.  
  2585. Name:       timer
  2586. Purpose:    returns the value of the BIOS timer
  2587. Prototype:  unsigned long timer(void);
  2588. Header:     tcxldef.h
  2589. Inputs:     none
  2590. Return:     current value of the BIOS timer
  2591. Also see:   delay_
  2592. Example:
  2593.             printf("%lu\n",timer());
  2594.             delay_(36);
  2595.             printf("%lu\n",timer());
  2596.  
  2597.  
  2598. Name:       touplow
  2599. Purpose:    converts a character to upper or lower case depending on previous
  2600.             character
  2601. Prototype:  int touplow(char *str,char *pos,int ch);
  2602. Header:     tcxlstr.h
  2603. Inputs:     str     - address of string
  2604.             pos     - current position in string
  2605.             ch      - character to convert
  2606. Return:     the converted character
  2607. Also see:   struplow
  2608. Example:
  2609.             char *str="Hello, world";
  2610.             printf("Before: %s\n",str);
  2611.             *(str+7)=touplow(str,str+7,*(str+7));
  2612.             printf("After:  %s\n",str);
  2613.  
  2614.  
  2615. Name:       videoinit
  2616. Purpose:    initializes TCXL's video system.  By default all TCXL functions
  2617.             performing direct screen writes go to the CGA video RAM segment at
  2618.             0xb800.  If you want these functions to work correctly with a
  2619.             monochrome video adapter or within a DESQview window, you must call
  2620.             this function.  This function sets the value of the global variable
  2621.             _videoseg
  2622. Prototype:  void videoinit(void);
  2623. Header:     tcxlvid.h  tcxlwin.h
  2624. Inputs:     none
  2625. Return:     none
  2626. Also see:   vidtype
  2627. Example:
  2628.             videoinit();
  2629.  
  2630.  
  2631. Name:       vidtype
  2632. Purpose:    determines the display adapter type
  2633. Prototype:  int vidtype(void);
  2634. Header:     tcxlvid.h
  2635. Inputs:     none
  2636. Return:     see TCXLVID.H for return values
  2637.  
  2638.  
  2639.                                       44   
  2640. Also see:   mode videoinit
  2641. Example:
  2642.             int i;
  2643.             i=vidtype();
  2644.             if(i<=HGCPLUS) printf("A color adapter is installed\n");
  2645.  
  2646.  
  2647. Name:       wactiv
  2648. Purpose:    activates a currently open window
  2649. Prototype:  int wactiv(int whandle);
  2650. Header:     tcxlwin.h
  2651. Inputs:     whandle     - the window handle returned from the wopen() function
  2652. Return:     W_NOERROR   - no error
  2653.             W_ALLOCERR  - memory allocation error
  2654.             W_NOTFOUND  - window handle not found
  2655.             W_NOACTIVE  - no open windows
  2656. Also see:   wisactiv wopen
  2657. Example:
  2658.             int w1,w2;
  2659.             w1=wopen(0,0,20,20,0,LMAGENTA|_RED);
  2660.             waitkey();
  2661.             w2=wopen(10,10,15,50,0,LGREEN|_BLUE);
  2662.             waitkey();
  2663.             wactiv(w1);
  2664.             waitkey();
  2665.             wactiv(w2);
  2666.             waitkey();
  2667.             wclose();
  2668.             wclose();
  2669.  
  2670.  
  2671. Name:       waitkey
  2672. Purpose:    halts execution until a key is pressed, the keyboard buffer is
  2673.             cleared first
  2674. Prototype:  int waitkey(void);
  2675. Header:     tcxlkey.h
  2676. Inputs:     none
  2677. Return:     the key pressed
  2678. Also see:   clearkeys getchf waitkeyt
  2679. Example:
  2680.             printf("Press any key to continue...");
  2681.             waitkey();
  2682.  
  2683.  
  2684. Name:       waitkeyt
  2685. Purpose:    halts execution until a key is pressed or the specified time limit
  2686.             expires, the keyboard buffer is cleared first
  2687. Prototype:  int waitkeyt(int duration);
  2688. Header:     tcxlkey.h
  2689. Inputs:     none
  2690. Return:     the key pressed or -1 if time expired before a key was pressed
  2691. Also see:   clearkeys delay_ getchf waitkey
  2692. Example:
  2693.             printf("Press any key to continue...");
  2694.             waitkeyt(182);                  /* wait for a max of 10 seconds */
  2695.  
  2696.  
  2697.  
  2698.  
  2699.                                       45   
  2700. Name:       wcclear
  2701. Purpose:    clears the currently active window using specified attribute
  2702. Prototype:  int wclear(int attr);
  2703. Header:     tcxlwin.h
  2704. Inputs:     none
  2705. Return:     W_NOERROR   - no error
  2706.             W_NOACTIVE  - no active window
  2707. Also see:   wactiv wclear wclreol
  2708. Example:
  2709.             wopen(10,10,20,20,0,WHITE|_GREEN);
  2710.             wprints(11,11,7,"Hello");
  2711.             wclear();
  2712.             waitkey();
  2713.             wclose();
  2714.  
  2715.  
  2716. Name:       wchgattr
  2717. Purpose:    changes attribute of the active window, all text within the window
  2718.             will be changed also
  2719. Prototype:  int wchgattr(int newattr);
  2720. Header:     tcxlwin.h
  2721. Inputs:     newattr  - the attribute to make the window
  2722. Return:     W_NOERROR   - no error
  2723.             W_NOACTIVE  - no active window
  2724. Also see:   wactiv wtextattr
  2725. Example:
  2726.             wopen(0,0,10,10,0,LCYAN|_BLUE);
  2727.             waitkey();
  2728.             wchgattr(LMAGENTA|_RED);
  2729.             waitkey();
  2730.             wclose();
  2731.  
  2732.  
  2733. Name:       wclear
  2734. Purpose:    clears the currently active window
  2735. Prototype:  int wclear(void);
  2736. Header:     tcxlwin.h
  2737. Inputs:     none
  2738. Return:     W_NOERROR   - no error
  2739.             W_NOACTIVE  - no active window
  2740. Also see:   wactiv wcclear wclreol
  2741. Example:
  2742.             wopen(10,10,20,20,0,WHITE|_GREEN);
  2743.             wprints(11,11,7,"Hello");
  2744.             wclear();
  2745.             waitkey();
  2746.             wclose();
  2747.  
  2748.  
  2749. Name:       wclose
  2750. Purpose:    closes the currently active window
  2751. Prototype:  int wclose(void);
  2752. Header:     tcxlwin.h
  2753. Inputs:     none
  2754. Return:     W_NOERROR   - no error
  2755.             W_ALLOCERR  - memory allocation error
  2756.             W_NOACTIVE  - no active window
  2757.  
  2758.  
  2759.                                       46   
  2760. Also see:   wactiv wcloseall wopen
  2761. Example:
  2762.             wopen(10,10,20,20,1,LCYAN|_BLUE);
  2763.             waitkey();
  2764.             wclose();
  2765.  
  2766.  
  2767. Name:       wcloseall
  2768. Purpose:    closes all open windows
  2769. Prototype:  int wcloseall(void);
  2770. Header:     tcxlwin.h
  2771. Inputs:     none
  2772. Return:     W_NOERROR   - no error
  2773.             W_ALLOCERR  - memory allocation error
  2774.             W_NOACTIVE  - no active window
  2775. Also see:   wclose
  2776. Example:
  2777.             wopen(0,0,10,10,1,LCYAN|_BLUE);
  2778.             wopen(5,5,15,15,0,LMAGENTA|_RED);
  2779.             wopen(10,10,20,20,1,YELLOW|_GREEN);
  2780.             waitkey();
  2781.             wcloseall();
  2782.  
  2783.  
  2784. Name:       wclreol
  2785. Purpose:    clears to the end of the active window's line
  2786. Prototype:  int wclreol(void);
  2787. Header:     tcxlwin.h
  2788. Inputs:     none
  2789. Return:     W_NOERROR   - no error
  2790.             W_NOACTIVE  - no active window
  2791. Also see:   wactiv wclear
  2792. Example:
  2793.             wopen(10,10,20,40,0,LMAGENTA|_RED);
  2794.             wputs("Hello, world");
  2795.             wgotoxy(0,5);
  2796.             wclreol();
  2797.             waitkey();
  2798.             wclose();
  2799.  
  2800.  
  2801. Name:       wcopy
  2802. Purpose:    creates a new window duplicating the active window, the new window
  2803.             becomes the active window
  2804. Prototype:  int wcopy(int nsrow,int nscol);
  2805. Header:     tcxlwin.h
  2806. Inputs:     nsrow   - start row of the duplicate window
  2807.             nscol   - start column of the duplicate window
  2808. Return:     the handle of the new window or a zero if an error occurred, the
  2809.             error code will be in the global variable _werrno, see TCXLWIN.H
  2810.             for error codes
  2811. Also see:   wactiv wmove
  2812. Example:
  2813.             wopen(11,11,20,40,0,LMAGENTA|_RED);
  2814.             wputs("Hello, world");
  2815.             waitkey();
  2816.             wcopy(0,0);
  2817.  
  2818.  
  2819.                                       47   
  2820.             waitkey();
  2821.             wclose();
  2822.             wclose();
  2823.  
  2824.  
  2825. Name:       werrmsg
  2826. Purpose:    returns an error message from the last windowing function
  2827. Prototype:  char *werrmsg(void);
  2828. Header:     tcxlwin.h
  2829. Inputs:     none
  2830. Return:     the address of a static string containing an error message
  2831.             corresponding to the error code from the last performed windowing
  2832.             function
  2833. Example:
  2834.             wopen(0,0,10,10,0,LCYAN|_BLUE);
  2835.             wgotoxy(255,255);
  2836.             printf("Error msg = %s\n",werrmsg());
  2837.  
  2838.  
  2839. Name:       wgetc
  2840. Purpose:    gets a character from the keyboard within the active window, echos
  2841.             character pressed to the screen in the attribute set by the
  2842.             wtextattr() function
  2843. Prototype:  int wgetc(void);
  2844. Header:     tcxlwin.h
  2845. Inputs:     none
  2846. Return:     the ASCII value of the key pressed or a zero if an error occurred,
  2847.             the error code will be in the global variable _werrno, see
  2848.             TCXLWIN.H for error codes
  2849. Also see:   wactiv wgetchf wtextattr
  2850. Example:
  2851.             wopen(0,0,5,30,0,LCYAN|_BLUE);
  2852.             wputs("Press a key:  ");
  2853.             wputs("\nYou pressed %c",wgetc());
  2854.             waitkey();
  2855.             wclose();
  2856.  
  2857.  
  2858. Name:       wgetchf
  2859. Purpose:    gets a character from the keyboard within the active window, allows
  2860.             only characters listed in the string of valid characters.  Escape
  2861.             checking is provided by default.  This can be turned off with the
  2862.             wsetesc() function.  Selected character is echoed into the current
  2863.             window using the attribute set by the wtextattr() function.
  2864. Prototype:  int wgetchf(char *valid);
  2865. Header:     tcxlwin.h
  2866. Inputs:     valid   - address of the string containing the valid characters
  2867. Return:     the ASCII value of the key pressed or a zero if an error occurred,
  2868.             the error code will be in the global variable _werrno, see
  2869.             TCXLWIN.H for error codes
  2870. Also see:   wactiv wgetc wtextattr
  2871. Example:
  2872.             wopen(0,0,5,30,0,LCYAN|_BLUE);
  2873.             wputs("Are you sure? ");
  2874.             wputs("\nYou pressed %c",wgetchf("YyNn"));
  2875.             waitkey();
  2876.             wclose();
  2877.  
  2878.  
  2879.                                       48   
  2880.  
  2881.  
  2882. Name:       wgetns
  2883. Purpose:    gets a string from the keyboard within active window, limits the
  2884.             number of characters input to specified length.  Escape checking
  2885.             is provided by default.  This can be turned off with the wsetesc()
  2886.             function.  Entered characters will echo to the active window
  2887.             in the attribute set by the wtextattr() function.
  2888. Prototype:  int wgetns(char *str,int maxlen);
  2889. Header:     tcxlwin.h
  2890. Inputs:     str     - address of the allocated space to receive the input
  2891.                       string
  2892.             maxlen  - the maximum length of the input string
  2893. Return:     W_NOERROR   - no error
  2894.             W_NOACTIVE  - no active window
  2895.             W_ESCPRESS  - Escape key was pressed
  2896. Also see:   wactiv wgets winputsf wscanf wtextattr
  2897. Example:
  2898.             char firstname[5];
  2899.             wopen(0,0,5,60,1,LCYAN|_BLUE);
  2900.             wputs("Enter your first name:  ");
  2901.             wgetns(firstname,5);
  2902.             wprintf("\nYour first name is:  %s",firstname);
  2903.             waitkey();
  2904.             wclose();
  2905.  
  2906.  
  2907. Name:       wgets
  2908. Purpose:    gets a string from the keyboard within active window, echos the
  2909.             characters to the screen in the attribute set by the wtextattr()
  2910.             function
  2911. Prototype:  int wgets(char *str);
  2912. Header:     tcxlwin.h
  2913. Inputs:     str     - the address of the string to receive the input characters
  2914. Return:     W_NOERROR   - no error
  2915.             W_NOACTIVE  - no active window
  2916. Also see:   wactiv wgetns winputsf wscanf wtextattr
  2917. Example:
  2918.             char fname[20];
  2919.             wopen(0,0,5,60,0,LCYAN|_BLUE);
  2920.             wputs("Enter your first name:  ");
  2921.             wgets(fname);
  2922.             wputs("\nYour first name is:  %s",fname);
  2923.             waitkey();
  2924.             wclose();
  2925.  
  2926.  
  2927. Name:       wgotoxy
  2928. Purpose:    plots cursor coordinates within the currently active window
  2929. Prototype:  int wgotoxy(int wrow,int wcol);
  2930. Header:     tcxlwin.h
  2931. Inputs:     wrow    - window row (Y coordinate)
  2932.             wcol    - window column (X coordinate)
  2933. Return:     W_NOERROR   - no error
  2934.             W_NOACTIVE  - no active window
  2935.             W_INVCOORD  - invalid coordinates
  2936. Also see:   wactiv wpgotoxy wreadcur
  2937.  
  2938.  
  2939.                                       49   
  2940. Example:
  2941.             wopen(0,0,10,10,0,YELLOW|_BLUE);
  2942.             wgotoxy(1,1);
  2943.             wputs("Hello");
  2944.  
  2945.  
  2946. Name:       whide
  2947. Purpose:    hides a previously saved window
  2948. Prototype:  int *whide(int **wbuf);
  2949. Header:     tcxlwin.h
  2950. Inputs:     wbuf    - address of the pointer to the window buffer to hide
  2951. Return:     the address of the hidden window's buffer or a NULL if a memory
  2952.             allocation error occurred
  2953. Also see:   wsave wunhide
  2954. Example:
  2955.             wopen(0,0,15,50,0,LCYAN|_BLUE);
  2956.             waitkey();
  2957.             whide(&_wrecord[_wcurrent].wbuf);   /* hides active window */
  2958.             waitkey();
  2959.             wunhide(&_wrecord[_wcurrent].wbuf);
  2960.             waitkey();
  2961.             wclose();
  2962.  
  2963.  
  2964. Name:       whline
  2965. Purpose:    draws a horizontal text line in active window using characters
  2966.             defined by given box type.  If horizontal line crosses a vertical
  2967.             line of the same box type, an appropriate intersection or corner
  2968.             will be used.
  2969. Prototype:  int whline(int wsrow,int wscol,int count,int btype);
  2970. Header:     tcxlwin.h
  2971. Inputs:     wsrow   - window start row of line
  2972.             wscol   - window start column of line
  2973.             count   - number of line characters to display
  2974.             btype   - box type (0-5)
  2975. Return:     W_NOERROR   - no error
  2976.             W_NOACTIVE  - no active window
  2977.             W_INVCOORD  - text line too long for window
  2978.             W_INVBTYPE  - invalid box type
  2979. Also see:   wtextattr wvline
  2980. Example:
  2981.             whline(2,5,7,3);
  2982.  
  2983.  
  2984. Name:       winpdef
  2985. Purpose:    defines an area of the active window for keyboard input.  See the
  2986.             section on multi-field input for details.
  2987. Prototype:  int winpdef(int wrow,int wcol,char *str,int ftype,int fattr);
  2988. Header:     tcxlwin.h
  2989. Inputs:     wrow    - start of input, window's row coordinate
  2990.             wcol    - start of input, window's column coordinate
  2991.             str     - address of string to input, must already be the length
  2992.                       the input is to be.  The string can be sized with the
  2993.                       strsetsz() function.  Contents of str will be displayed
  2994.                       before keyboard input.
  2995.             ftype   - input field type, must be a valid character type code,
  2996.                       see the section on using window input functions for a
  2997.  
  2998.  
  2999.                                       50   
  3000.                       list of valid character type codes.
  3001.             fattr   - field attribute
  3002. Return:     W_NOERROR   - no error
  3003.             W_ALLOCERR  - memory allocation error
  3004.             W_NOACTIVE  - no active window
  3005. Also see:   winpread winputsf winpxcel wscanf
  3006. Example:
  3007.             char *str1;
  3008.             char *str2;
  3009.             wopen(0,0,10,40,0,LCYAN|_BLUE);
  3010.             wgotoxy(1,1);
  3011.             wputs("Enter name:");
  3012.             strsetsz(&str1,15);
  3013.             winpdef(1,15,str1,'M');
  3014.             wgotoxy(3,1);
  3015.             wputs("Enter phone:");
  3016.             strsetsz(&str2,7);
  3017.             winpdef(3,15,str2,'#');
  3018.             winpread();
  3019.             wprintf("Name is %s, phone is %s\n",str1,str2);
  3020.  
  3021.  
  3022. Name:       winpread
  3023. Purpose:    processes keyboard input of all defined areas of active window
  3024.             allowing editing back and forth between defined fields.  When
  3025.             carriage return is pressed in the last field, all fields will be
  3026.             processed. If the Escape key is pressed while Escape checking is
  3027.             on, all defined fields will be cancelled and an error code will be
  3028.             returned.  Valid editing keys are:  BackSpace, Ctrl-End,
  3029.             Ctrl-Enter, Ctrl-Home, Del, End, Enter, Esc, Home, Ins, Shift-Tab,
  3030.             Tab, and the arrow keys.
  3031. Prototype:  int winpread(void);
  3032. Header:     tcxlwin.h
  3033. Inputs:     none
  3034. Return:     W_NOERROR   - no error
  3035.             W_NOACTIVE  - no active window
  3036.             W_ESCPRESS  - Escape key was pressed
  3037.             W_NOINPDEF  - no inputs defined, see description for winpdef()
  3038. Also see:   winpdef winpxcel wtextattr
  3039.  
  3040.  
  3041. Name:       winputsf
  3042. Purpose:    inputs a formatted string from the keyboard within a window
  3043. Prototype:  int winputsf(char *str,char *fmt);
  3044. Header:     tcxlwin.h
  3045. Inputs:     str     - address of the allocated space to receive string
  3046.             fmt     - address of the format string, see section on using format
  3047.                       strings
  3048. Return:     W_NOERROR   - no error
  3049.             W_NOACTIVE  - no active window
  3050.             W_ESCPRESS  - Escape key was pressed
  3051.             W_INVFORMT  - invalid format string
  3052. Also see:   wgetns wgets winpdef wscanf wtextattr
  3053. Example:
  3054.             char str[255];
  3055.             wopen(0,0,10,40,0,LMAGENTA|_RED);
  3056.             winputsf(str,!RE!'Enter phone number:  ('###') '###'-'####");
  3057.  
  3058.  
  3059.                                       51   
  3060.             wputs("\nYour phone number is:  ");
  3061.             wputs(str);
  3062.  
  3063.  
  3064. Name:       winpxcel
  3065. Purpose:    cancels keyboard of all defined areas of active window
  3066. Prototype:  int winpxcel(void);
  3067. Header:     tcxlwin.h
  3068. Inputs:     none
  3069. Return:     W_NOERROR   - no error
  3070.             W_NOACTIVE  - no active window
  3071. Also see:   winpdef winpread
  3072. Example:
  3073.             char *str1="                    ";
  3074.             wopen(0,0,10,40,0,LCYAN|_BLUE);
  3075.             wgotoxy(1,1);
  3076.             wputs("Enter name:");
  3077.             winpdef(1,15,str1,'M');
  3078.             winpxcel();
  3079.             wgotoxy(3,1);
  3080.             wputs("Enter phone:");
  3081.             winpdef(3,15,str1,'#');
  3082.             winpread();
  3083.             wprintf("phone is %s\n",str1);
  3084.  
  3085.  
  3086. Name:       wintodisk
  3087. Purpose:    copies a screen window to a disk file
  3088. Prototype:  int wintodisk(int srow,int scol,int erow,int ecol,char *fname);
  3089. Header:     tcxlwin.h
  3090. Inputs:     srow    - starting row
  3091.             scol    - starting column
  3092.             erow    - ending row
  3093.             ecol    - ending column
  3094.             fname   - address of the string containing file to write to
  3095. Return:     a zero if no error
  3096. Also see:   disktowin scrntodisk wsave
  3097. Example:
  3098.             if(wintodisk(10,10,20,20,"WINDOW.DAT")) {
  3099.                 printf("Error creating file\n");
  3100.                 exit(1);
  3101.             }
  3102.  
  3103.  
  3104. Name:       wisactiv
  3105. Purpose:    determines if specified window handle is active
  3106. Prototype:  int wisactiv(int whandle);
  3107. Header:     tcxlwin.h
  3108. Inputs:     whandle - the handle of the window to check
  3109. Return:     a zero if handle is not active, a 1 if it is active
  3110. Also see:   wactiv
  3111. Example:
  3112.             printf("handle 5 is %sactive\n",wisactiv(5)?"":"not ");
  3113.  
  3114.  
  3115. Name:       wmbardef
  3116. Purpose:    defines a window bar-selection menu option.  See the section on
  3117.  
  3118.  
  3119.                                       52   
  3120.             using bar selection menus for more information.
  3121. Prototype:  int wmbardef(int wrow,int wcol,int attr,char *str,int tagchar);
  3122. Header:     tcxlwin.h
  3123. Inputs:     wrow    - window row to display option at
  3124.             wcol    - window column to display option at
  3125.             attr    - attribute to display option with
  3126.             str     - address of the option string
  3127.             tagchar - tag character to use for identification, must be
  3128.                       alphanumeric, case is insensitive
  3129. Return:     W_NOERROR   - no error
  3130.             W_ALLOCERR  - memory allocation error
  3131.             W_NOACTIVE  - no active window
  3132.             W_INVTAGCH  - invalid tag character
  3133. Also see:   wmbarget wmbarxcel
  3134. Example:
  3135.             if(wmbardef(2,3,LCYAN|_BLUE,"Add record",'A')) {
  3136.                 printf("Error:  %s\n",werrmsg());
  3137.                 exit(1);
  3138.             }
  3139.  
  3140.  
  3141. Name:       wmbarget
  3142. Purpose:    gets a window bar-selection menu selection from the keyboard.  The
  3143.             user is allowed to use the cursor keys or the specified tag
  3144.             character to select the option.  After a selection is made, all
  3145.             defined options are cleared.  Escape checking is on by default, but
  3146.             can be turned off with the wsetesc() function.  See section on
  3147.             using bar-selection menus for more details.
  3148. Prototype:  int wmbarget(int barattr,int taginit,int pulldown);
  3149. Header:     tcxlwin.h
  3150. Inputs:     barattr   - the attribute to use for the selection bar
  3151.             taginit   - tag character of initial selection bar position.  If an
  3152.                         invalid tag character is specified, the position
  3153.                         defaults to the upper left.
  3154.             pulldown  - can one of the following values:
  3155.                             0       - not part of a pull-down menu system
  3156.                             PDMAIN  - main menu of a pull-down menu system
  3157.                             PDPREV  - main menu, automatically select the
  3158.                                       previous pull-down menu
  3159.                             PDNEXT  - main menu, automatically select the next
  3160.                                       pull-down menu
  3161.                             PDMENU  - pull-down menu
  3162. Return:     the tag character of the selected option or zero if an error.  If
  3163.             error, the error code will be in the global variable _werrno.  See
  3164.             TCXLWIN.H for error codes.  If PDMENU is specified for the pulldown
  3165.             parameter, then this function will return PDPREV if LeftArrow is
  3166.             pressed and PDNEXT if RightArrow is pressed.
  3167. Also see:   wmbardef wmbarxcel
  3168. Example:
  3169.             option=wmbarget(LCYAN|_GREEN,'A',0);
  3170.             switch(option) {
  3171.                 case 'A':
  3172.                     ......
  3173.                 case 'D':
  3174.                     ......
  3175.                 case 0:
  3176.                     error_routine();
  3177.  
  3178.  
  3179.                                       53   
  3180.                 etc.
  3181.             }
  3182.  
  3183.  
  3184. Name:       wmbarxcel
  3185. Purpose:    cancels all window bar menu options defined before wmbarget() is
  3186.             called.
  3187. Prototype:  int wmbarxcel(void);
  3188. Header:     tcxlwin.h
  3189. Inputs:     none
  3190. Return:     W_NOERROR   - no error
  3191.             W_NOACTIVE  - no active window
  3192. Also see:   wmbardef wmbarget
  3193. Example:
  3194.             if(wmbarxcel()) {
  3195.                 printf("Error:  %s\n",werrmsg());
  3196.                 exit(1);
  3197.             }
  3198.  
  3199.  
  3200. Name:       wmove
  3201. Purpose:    moves the currently active window to a new location
  3202. Prototype:  int wmove(int nsrow,int nscol);
  3203. Header:     tcxlwin.h
  3204. Inputs:     nsrow   - new starting row of window
  3205.             nscol   - new starting column of window
  3206. Return:     W_NOERROR   - no error
  3207.             W_ALLOCERR  - memory allocation error
  3208.             W_NOACTIVE  - no active window
  3209. Also see:   wcopy wsize
  3210. Example:
  3211.             wopen(10,10,20,20,2,LCYAN|_BLUE);
  3212.             waitkey();
  3213.             if(wmove(0,0)) {
  3214.                 printf("Error:  %s\n",werrmsg());
  3215.                 exit(1);
  3216.             }
  3217.  
  3218.  
  3219. Name:       wnopen
  3220. Purpose:    returns the number of open windows
  3221. Prototype:  int wnopen(void);
  3222. Header:     tcxlwin.h
  3223. Inputs:     none
  3224. Return:     the number of open windows
  3225. Also see:   wclose wcloseall wopen
  3226. Example:
  3227.             printf("There are %d windows open\n",wnopen());
  3228.  
  3229.  
  3230. Name:       wopen
  3231. Purpose:    opens a screen window and makes it active, the cursor location
  3232.             will be initialized to window row 0, column 0, and the text
  3233.             attribute will be initialized to the same attribute as the window
  3234. Prototype:  int wopen(int srow,int scol,int erow,int ecol,int btype,int attr);
  3235. Header:     tcxlwin.h
  3236. Inputs:     srow    - starting row, upper left corner
  3237.  
  3238.  
  3239.                                       54   
  3240.             scol    - starting column, upper left corner
  3241.             erow    - ending row, lower right corner
  3242.             ecol    - ending column, lower right corner
  3243.             btype   - box type (0-5)
  3244.             attr    - attribute of window
  3245. Return:     the window handle of the new window or a zero if an error occurred,
  3246.             the error code will be in the global variable _werrno, see
  3247.             TCXLWIN.H for error codes
  3248. Also see:   videoinit wactiv wclose wcloseall wnopen
  3249. Example:
  3250.             wopen(10,10,20,20,0,LCYAN|_BLUE);
  3251.  
  3252.  
  3253. Name:       wpgotoxy
  3254. Purpose:    plots pseudo cursor coordinates within the currently active window
  3255.             by wrapping around if coordinates are out of range
  3256. Prototype:  int wpgotoxy(int wrow,int wcol);
  3257. Header:     tcxlwin.h
  3258. Inputs:     wrow    - window row (Y coordinate)
  3259.             wcol    - window column (X coordinate)
  3260. Return:     W_NOERROR   - no error
  3261.             W_NOACTIVE  - no active window
  3262.             W_INVCOORD  - invalid coordinates
  3263. Also see:   wactiv wgotoxy wreadcur
  3264. Example:
  3265.             wopen(0,0,10,10,0,YELLOW|_BLUE);
  3266.             wpgotoxy(3,20);
  3267.             wputs("Hello");
  3268.  
  3269.  
  3270. Name:       wprintc
  3271. Purpose:    prints a character in the currently active window, does not adjust
  3272.             cursor position, recognizes no control codes
  3273. Prototype:  int wprintc(int row,int col,int attr,int ch);
  3274. Header:     tcxlwin.h
  3275. Inputs:     row     - cursor row (of the window)
  3276.             col     - cursor column (of the window)
  3277.             attr    - character attribute
  3278.             ch      - character
  3279. Return:     W_NOERROR   - no error
  3280.             W_NOACTIVE  - no active window
  3281.             W_INVCOORD  - invalid coordinates
  3282. Also see:   wactiv wputc
  3283. Example:
  3284.             wopen(10,10,20,20,0,WHITE|_GREEN);
  3285.             wprintc(11,11,7,"T");
  3286.  
  3287.  
  3288. Name:       wprintf
  3289. Purpose:    outputs a formatted string to active window, works just like
  3290.             printf() does
  3291. Prototype:  int wprintf(const char *format,...);
  3292. Header:     tcxlwin.h
  3293. Inputs:     format  - format string, refer to Turbo C manual under printf()
  3294.             ...     - any additional arguments
  3295. Return:     W_NOERROR   - no error
  3296.             W_ALLOCERR  - memory allocation error
  3297.  
  3298.  
  3299.                                       55   
  3300.             W_NOACTIVE  - no active window
  3301. Also see:   wactiv wputc wputns wputs wtextattr
  3302. Example:
  3303.             char str="world";
  3304.             wopen(0,0,10,20,0,LMAGENTA|_RED);
  3305.             wprintf("Hello, %s\n",str);
  3306.  
  3307.  
  3308. Name:       wprints
  3309. Purpose:    prints a string in the currently active window, does not adjust
  3310.             cursor position, recognizes no control codes
  3311. Prototype:  int wprints(int row,int col,int attr,char *str);
  3312. Header:     tcxlwin.h
  3313. Inputs:     row     - cursor row (of the window)
  3314.             col     - cursor column (of the window)
  3315.             attr    - attribute
  3316.             str     - address of string
  3317. Return:     W_NOERROR   - no error
  3318.             W_NOACTIVE  - no active window
  3319.             W_INVCOORD  - invalid coordinates
  3320.             W_STRLONG   - string too long for window
  3321. Also see:   wactiv wprintf wputns wputs
  3322. Example:
  3323.             wopen(10,10,20,20,0,WHITE|_GREEN);
  3324.             wprints(11,11,7,"Hello");
  3325.             waitkey();
  3326.             wclose();
  3327.  
  3328.  
  3329. Name:       wputc
  3330. Purpose:    prints a character in currently active window at current cursor
  3331.             location, uses attribute set by the wtextattr() function,
  3332.             recognizes the '\n', '\r', '\t', '\7' and '\b' control characters
  3333. Prototype:  int wputc(int ch);
  3334. Header:     tcxlwin.h
  3335. Inputs:     ch  - the character to be printed
  3336. Return:     W_NOERROR   - no error
  3337.             W_NOACTIVE  - no active window
  3338. Also see:   wactiv wprintc wprintf wtextattr
  3339. Example:
  3340.             wopen(10,10,20,20,0,WHITE|_GREEN);
  3341.             wgotoxy(5,5);
  3342.             wtextattr(LMAGENTA|BLINK);
  3343.             wputc('X');
  3344.  
  3345.  
  3346. Name:       wputns
  3347. Purpose:    prints a string in the active window, formatting width of output,
  3348.             uses attribute set by the wtextattr() function, recognizes the
  3349.             '\n', '\r', '\t', '\7' and '\b' control characters
  3350. Prototype:  int wputns(char *str,int width);
  3351. Header:     tcxlwin.h
  3352. Inputs:     str     - address of the string to print
  3353.             width   - width to display output string with
  3354. Return:     W_NOERROR   - no error
  3355.             W_NOACTIVE  - no active window
  3356. Also see:   wactiv wprintf wprints wputs wtextattr
  3357.  
  3358.  
  3359.                                       56   
  3360. Example:
  3361.             wopen(10,10,20,20,2,WHITE|_GREEN);
  3362.             wtextattr(LMAGENTA|BLINK);
  3363.             wputns("Hello, world",5);
  3364.  
  3365.  
  3366. Name:       wputs
  3367. Purpose:    prints a string in currently active window at the current cursor
  3368.             location, uses attribute set by the wtextattr() function,
  3369.             recognizes the '\n', '\r', '\t', '\7' and '\b' control characters
  3370. Prototype:  int wputs(char *str);
  3371. Header:     tcxlwin.h
  3372. Inputs:     str     - the address of the string to print
  3373. Return:     W_NOERROR   - no error
  3374.             W_NOACTIVE  - no active window
  3375. Also see:   wactiv wprintf wprints wputns wtextattr
  3376. Example:
  3377.             wopen(10,10,20,20,0,WHITE|_GREEN);
  3378.             wgotoxy(1,1);
  3379.             wtextattr(LMAGENTA|BLINK);
  3380.             wputs("Hello, world");
  3381.  
  3382.  
  3383. Name:       wrestore
  3384. Purpose:    restores a previously saved window of screen memory
  3385. Prototype:  void wrestore(int *wbuf);
  3386. Header:     tcxlwin.h
  3387. Inputs:     wbuf    - address of previously saved window
  3388. Return:     none
  3389. Also see:   srestore wsave wunhide
  3390. Example:
  3391.             int *wbuf;
  3392.             wbuf=wsave(7,7,18,60);
  3393.             clrscrn();
  3394.             wrestore(wbuf);
  3395.  
  3396.  
  3397. Name:       wsave
  3398. Purpose:    saves a window of screen memory
  3399. Prototype:  int *wsave(int srow,int scol,int erow,int ecol);
  3400. Header:     tcxlwin.h
  3401. Inputs:     srow    - starting row, upper left corner
  3402.             scol    - starting column, upper left corner
  3403.             erow    - ending row, lower right corner
  3404.             ecol    - ending column, lower right corner
  3405. Return:     address of newly created window buffer or NULL if a memory
  3406.             allocation error occurred.
  3407. Also see:   ssave videoinit whide wintodisk wrestore
  3408. Example:
  3409.             int *wbuf;
  3410.             wbuf=wsave(7,7,18,60);
  3411.             clrscrn();
  3412.             wrestore(wbuf);
  3413.  
  3414.  
  3415. Name:       wscanf
  3416. Purpose:    inputs a formatted string from keyboard, works like scanf() does
  3417.  
  3418.  
  3419.                                       57   
  3420. Prototype:  int wscanf(const char *format,...);
  3421. Header:     tcxlwin.h
  3422. Inputs:     format  - format string, refer to Turbo C manual under scanf()
  3423.             ...     - any additional arguments
  3424. Return:     W_NOERROR   - no error
  3425.             W_ALLOCERR  - memory allocation error
  3426.             W_NOACTIVE  - no active window
  3427. Also see:   wactiv wgetc wgets winpdef winputsf wtextattr
  3428.  
  3429.  
  3430. Name:       wscroll
  3431. Purpose:    scrolls text within the active window, up or down
  3432. Prototype:  int wscroll(int count,int direction);
  3433. Header:     tcxlwin.h
  3434. Inputs:     count       - number of lines to scroll
  3435.             direction   - a 0 to scroll down or non-zero to scroll up
  3436. Return:     W_NOERROR   - no error
  3437.             W_NOACTIVE  - no active window
  3438. Also see:   wactiv
  3439. Example:
  3440.             wopen(10,10,20,20,0,WHITE|_GREEN);
  3441.             wprints(11,11,7,"Hello");
  3442.             waitkey();
  3443.             wscroll(2,DOWN);
  3444.  
  3445.  
  3446. Name:       wsetesc
  3447. Purpose:    sets the Escape checking for window keyboard input functions that
  3448.             allow Escape checking
  3449. Prototype:  void wsetesc(int option);
  3450. Header:     tcxlwin.h
  3451. Inputs:     option  - (0-1), 0 = turn Escape checking off, 1 = turn Escape
  3452.                       checking on
  3453. Return:     none
  3454. Also see:   wgetchf wgetns winputsf wmbarread winpread
  3455. Example:
  3456.             wsetesc(ON);    /* turns Escape checking on */
  3457.  
  3458.  
  3459. Name:       wsize
  3460. Purpose:    adjusts the size of the active window
  3461. Prototype:  int wsize(int nerow,int necol);
  3462. Header:     tcxlwin.h
  3463. Inputs:     nerow   - new end row of sized window
  3464.             necol   - new end column of sized window
  3465. Return:     W_NOERROR   - no error
  3466.             W_ALLOCERR  - memory allocation error
  3467.             W_NOACTIVE  - no active window
  3468.             W_INVCOORD  - invalid coordinates
  3469. Also see:   wactiv wcopy wmove
  3470. Example:
  3471.             wopen(10,10,20,20,0,WHITE|_GREEN);
  3472.             waitkey();
  3473.             wsize(23,40);
  3474.             waitkey();
  3475.             wsize(15,15);
  3476.  
  3477.  
  3478.  
  3479.                                       58   
  3480.  
  3481. Name:       wtextattr
  3482. Purpose:    sets the default text attribute for text displayed in active window
  3483. Prototype:  int wtextattr(int attr);
  3484. Header:     tcxlwin.h
  3485. Inputs:     attr    - the new text attribute
  3486. Return:     a zero if no error, see TCXLWIN.H for error codes
  3487. Also see:   attrib wchgattr
  3488. Example:
  3489.             wopen(10,10,20,20,0,WHITE|_GREEN);
  3490.             wgotoxy(1,1);
  3491.             wtextattr(LMAGENTA|BLINK);
  3492.             wputs("Hello, world");
  3493.  
  3494.  
  3495. Name:       wtitle
  3496. Purpose:    gives active window a title and displays title on top border line
  3497.             of window
  3498. Prototype:  int wtitle(char *str,int tpos);
  3499. Header:     tcxlwin.h
  3500. Inputs:     str     - address of title string or NULL to delete title
  3501.             tpos    - position of title:
  3502.                         TDELETE - to delete title
  3503.                         TLEFT   - left justified
  3504.                         TCENTER - centered
  3505.                         TRIGHT  - right justified
  3506. Return:     W_NOERROR   - no error
  3507.             W_NOACTIVE  - no active window
  3508.             W_TITLLONG  - title string too long for window
  3509.             W_INVTPOS   - invalid title position argument
  3510. Example:
  3511.             wtitle("[ My Window ]",TCENTER);
  3512.  
  3513.  
  3514. Name:       wunhide
  3515. Purpose:    unhides a previously hidden window
  3516. Prototype:  int *wunhide(int **wbuf);
  3517. Header:     tcxlwin.h
  3518. Inputs:     wbuf    - address of the pointer to the window buffer to unhide
  3519. Return:     the address of the unhidden window's buffer or a NULL if a memory
  3520.             allocation error occurred
  3521. Also see:   whide wrestore
  3522. Example:
  3523.             wopen(0,0,15,50,0,LCYAN|_BLUE);
  3524.             waitkey();
  3525.             whide(&_wrecord[_wcurrent].wbuf);
  3526.             waitkey();
  3527.             wunhide(&_wrecord[_wcurrent].wbuf);
  3528.  
  3529.  
  3530. Name:       wvline
  3531. Purpose:    draws a vertical text line in active window using characters
  3532.             defined by given box type.  If vertical line crosses a horizontal
  3533.             line of the same box type, an appropriate intersection or corner
  3534.             will be used.
  3535. Prototype:  int wvline(int wsrow,int wscol,int count,int btype);
  3536. Header:     tcxlwin.h
  3537.  
  3538.  
  3539.                                       59   
  3540. Inputs:     wsrow   - window start row of line
  3541.             wscol   - window start column of line
  3542.             count   - number of line characters to display
  3543.             btype   - box type (0-5)
  3544. Return:     W_NOERROR   - no error
  3545.             W_NOACTIVE  - no active window
  3546.             W_INVCOORD  - entire text line could not fit in window
  3547.             W_INVBTYPE  - invalid box type
  3548. Also see:   whline wtextattr
  3549. Example:
  3550.             wvline(3,9,14,1);
  3551.  
  3552.  
  3553.  
  3554.  
  3555.  
  3556.  
  3557.  
  3558.  
  3559.  
  3560.  
  3561.  
  3562.  
  3563.  
  3564.  
  3565.  
  3566.  
  3567.  
  3568.  
  3569.  
  3570.  
  3571.  
  3572.  
  3573.  
  3574.  
  3575.  
  3576.  
  3577.  
  3578.  
  3579.  
  3580.  
  3581.  
  3582.  
  3583.  
  3584.  
  3585.  
  3586.  
  3587.  
  3588.  
  3589.  
  3590.  
  3591.  
  3592.  
  3593.  
  3594.  
  3595.  
  3596.  
  3597.  
  3598.  
  3599.                                       60   
  3600.  
  3601.                               Global Variables
  3602.                               ----------------
  3603.  
  3604. Name:       _videoseg
  3605. Purpose:    contains the current video RAM segment address used by direct
  3606.             screen writes
  3607. Type:       unsigned
  3608.  
  3609.  
  3610. Name:       _wcurrent
  3611. Purpose:    contains the array subscript of the window record that is currently
  3612.             active
  3613. Type:       int
  3614.  
  3615.  
  3616. Name:       _werrno
  3617. Purpose:    contains the error code from the most recently performed windowing
  3618.             function.  See TCXLWIN.H for error codes.
  3619. Type:       int
  3620.  
  3621.  
  3622. Name:       _wesc
  3623. Purpose:    Escape key checking flag.  This is set by the wsetesc() function
  3624.             and used by several window keyboard input functions.
  3625. Type:       int
  3626.  
  3627.  
  3628. Name:       _whandle
  3629. Purpose:    contains the last handle number given to a window
  3630. Type:       int
  3631.  
  3632.  
  3633. Name:       _winpcurr
  3634. Purpose:    contains the subscript of the window input record array
  3635. Type:       int
  3636.  
  3637.  
  3638. Name:       _winprec
  3639. Purpose:    a pointer to an array of defined window input records
  3640. Type:       struct _winprec *  (see TCXLWIN.H for definition)
  3641.  
  3642.  
  3643. Name:       _wmbarlast
  3644. Purpose:    contains the array subscript of the highest defined bar-menu option
  3645. Type:       int
  3646.  
  3647.  
  3648. Name:       _wmbarrec
  3649. Purpose:    a pointer to the array of defined bar-menu options
  3650. Type:       struct _wmbarrec *  (See TCXLWIN.H for definition)
  3651.  
  3652.  
  3653. Name:       _wrecord
  3654. Purpose:    a pointer to an array of window records which contains window
  3655.             handles and window buffer pointers
  3656. Type:       struct _wrecord *  (see TCXLWIN.H for definition) 
  3657.  
  3658.  
  3659.                                       61   
  3660.