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