home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / INFO / TURBOPAS / QWIK5X.ZIP / QWIK5X.DOC next >
Encoding:
Text File  |  1988-12-20  |  41.2 KB  |  1,109 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.  
  8.  
  9.  
  10.  
  11.  
  12.  
  13.  
  14.  
  15.  
  16.  
  17.  
  18.  
  19.  
  20.                               QWIK SCREEN UTILITIES
  21.                                    USER'S GUIDE
  22.  
  23.                                    Version 5.x
  24.                                 December 20, 1988
  25.  
  26.  
  27.                   Copyright (C) 1988 Eagle Performance Software
  28.                               All Rights Reserved.
  29.  
  30.  
  31.  
  32.                                _______                     
  33.                           ____| _     |               (tm) 
  34.                        --|       |    |------------------- 
  35.                          |   ____|__  |  Association of    
  36.                          |  |       |_|  Shareware         
  37.                          |__|   o   |    Professionals     
  38.                        -----|   |   |--------------------- 
  39.                             |___|___|    MEMBER            
  40.  
  41.  
  42.    QWIK Screen Utilities                             User's Guide, Version 5.x
  43.  
  44.  
  45.  
  46.                        T A B L E   O F   C O N T E N T S
  47.  
  48.         1. INTRODUCTION  . . . . . . . . . . . . . . . . . . . . . 3
  49.              Features .  . . . . . . . . . . . . . . . . . . . . . 3
  50.              Using the Manuals . . . . . . . . . . . . . . . . . . 3
  51.              Licensing . . . . . . . . . . . . . . . . . . . . . . 4
  52.              Customer Service  . . . . . . . . . . . . . . . . . . 4
  53.              ASP . . . . . . . . . . . . . . . . . . . . . . . . . 5
  54.  
  55.         2. GETTING STARTED . . . . . . . . . . . . . . . . . . . . 6
  56.              Distribution Files  . . . . . . . . . . . . . . . . . 6
  57.              Demonstration . . . . . . . . . . . . . . . . . . . . 6
  58.              Simple Programming  . . . . . . . . . . . . . . . . . 6
  59.              Procedures and Functions  . . . . . . . . . . . . . . 8
  60.  
  61.         3. BASIC TECHNIQUES  . . . . . . . . . . . . . . . . . . . 11
  62.              Number to String Conversion . . . . . . . . . . . . . 11
  63.              Cursor Mode Routines  . . . . . . . . . . . . . . . . 11
  64.              Cursor Location Routines  . . . . . . . . . . . . . . 13
  65.              EOS Marker  . . . . . . . . . . . . . . . . . . . . . 13
  66.              Scrolling . . . . . . . . . . . . . . . . . . . . . . 14
  67.              Pop-Up Windows  . . . . . . . . . . . . . . . . . . . 15
  68.  
  69.         4. ADVANCED TECHNIQUES . . . . . . . . . . . . . . . . . . 17
  70.              Virtual Screens . . . . . . . . . . . . . . . . . . . 17
  71.              Video Pages . . . . . . . . . . . . . . . . . . . . . 18
  72.              Video Modes . . . . . . . . . . . . . . . . . . . . . 19
  73.              Multi-tasking Environments  . . . . . . . . . . . . . 20
  74.              Interrupts  . . . . . . . . . . . . . . . . . . . . . 20
  75.  
  76.         5. HARDWARE DETECTION  . . . . . . . . . . . . . . . . . . 21
  77.              Display Combination Code  . . . . . . . . . . . . . . 21
  78.              Snow Checking . . . . . . . . . . . . . . . . . . . . 22
  79.              System Hardware . . . . . . . . . . . . . . . . . . . 23
  80.              Tips  . . . . . . . . . . . . . . . . . . . . . . . . 23
  81.  
  82.         APPENDIX A: Video Mode Table . . . . . . . . . . . . . . . 24
  83.  
  84.         APPENDIX B: Cursor Mode Data . . . . . . . . . . . . . . . 26
  85.              Cursor Mode Tables  . . . . . . . . . . . . . . . . . 26
  86.              Cursor Emulation  . . . . . . . . . . . . . . . . . . 26
  87.  
  88.         APPENDIX C: Performance  . . . . . . . . . . . . . . . . . 29
  89.              Code Size . . . . . . . . . . . . . . . . . . . . . . 29
  90.              Speed . . . . . . . . . . . . . . . . . . . . . . . . 29
  91.              TP4 Usage . . . . . . . . . . . . . . . . . . . . . . 30
  92.  
  93.         APPENDIX D: Application Products . . . . . . . . . . . . . 31
  94.  
  95.         APPENDIX E: Revision History . . . . . . . . . . . . . . . 34
  96.  
  97.         APPENDIX F: References and Credits . . . . . . . . . . . . 37
  98.  
  99.  
  100.  
  101.  
  102.                                        2
  103.    QWIK Screen Utilities                             User's Guide, Version 5.x
  104.  
  105.  
  106.    1.  I N T R O D U C T I O N
  107.  
  108.  
  109.    FEATURES
  110.  
  111.    Welcome to QWIK Screen Utilities!  
  112.  
  113.    You have just obtained a copy of the highest performance screen writing 
  114.    tools available today for Turbo Pascal 5.0 (TP5).  Both novice and 
  115.    professional programmers will appreciate these simple and very powerful 
  116.    utilities that gives you absolute control over your CRT displays in all 
  117.    text modes.
  118.    
  119.    Here are some of the features you will discover:
  120.  
  121.      . Writes on all IBM compatible computers, displays and 
  122.        adapters including the new PS/2 systems and Hercules.
  123.      . Superior video detection routine.
  124.      . Eliminates snow and flicker.
  125.      . Writes directly to the screen in absolute coordinates.
  126.      . Writes in all text modes and column modes.
  127.      . Writes on all video pages.
  128.      . Writes on virtual screens in RAM.
  129.      . Writes text and attribute, text only, or attribute only.
  130.      . Reads strings, characters and attributes.
  131.      . Uses End-Of-String (EOS) marker for quick string chaining.
  132.      . Provides standardized cursor control for all adapters.
  133.      . Enhanced cursor movement.
  134.      . 650% faster than TP5 direct screen writing.
  135.      . Only 2.7k bytes of code if all 43 utilities are used.
  136.      . Optimized by the compiler and drops unused code.
  137.      . Used in all other Eagle products.
  138.  
  139.    QWIK is an enhancement unit providing capabilities not offered in the CRT 
  140.    unit that came with TP5.  In contrast to the CRT unit which does window 
  141.    relative writing, QWIK knows how to write directly to the screen in 
  142.    absolute screen coordinates for any video configuration.
  143.  
  144. |  Version 5X - This version is simply a TP5 compiled version of QWIK42B.  
  145. |  QWIK50 will be out at a later date with other features specific to TP5.
  146.  
  147.  
  148.    USING THE MANUALS
  149.  
  150.    Disk Based Guides - The manuals for QWIK are on disk so that you can 
  151.    conveniently scan for the topic you are seeking.  You can do this with any 
  152.    list or search utility with a search function.  You can also make a printed 
  153.    copy.  If you have not already printed this manual, refer to the READ.ME 
  154.    file for instructions.  At the present time, no bound manuals are being 
  155.    offered with registration.
  156.  
  157.    User's Guide - This manual, the one your are reading now, assumes that as a 
  158.    programmer you are already familiar with Turbo Pascal 4.0.  And that you 
  159.    have a working knowledge of your disk operating system (DOS).  It will 
  160.    provide you the basic principles of direct screen writing and powerful tips 
  161.  
  162.  
  163.    Chapter 1, Introduction                                             Page 3
  164.    QWIK Screen Utilities                             User's Guide, Version 5.x
  165.  
  166.  
  167.    on some previously unavailable techniques.
  168.  
  169.    Reference Guide - This manual describes in detail all procedures, functions 
  170.    and variables used in QWIK.  It is a alphabetically arranged for easy 
  171.    access in a format similar to the TP5 manual.  Use this manual when you 
  172.    have become familiar with the basic principles in the User's guide.
  173.  
  174.  
  175.    LICENSING
  176.  
  177.    Registration - These utilities and the documentation have been released for 
  178.    distribution as Shareware.  You have been given the chance to sample the 
  179.    full capability of QWIK without risk!  If you find that QWIK is a valuable 
  180.    tool, then you are expected to register.  You will find a reasonable 
  181.    licensing schedule found in LICENSE.ARC to meet private or commercial 
  182.    needs.  When registering, be sure to specify the version for Turbo Pascal 
  183.    (such as TP4 or TP5) you wish to receive.
  184.  
  185.    Source Code - All registered users will receive source code when the signed 
  186.    license agreement is returned with the registration.
  187.  
  188.  
  189.    CUSTOMER SERVICE
  190.  
  191.    If you have questions, comments, or suggestions, the Eagle can be contacted 
  192.    by three means - (1) CompuServe, (2) telephone, (3) The Eagle BBS, or 
  193.    (4) mail.
  194.  
  195.    CompuServe - The most dependable way to contact the Eagle is through 
  196.    CompuServe.  James (Jim) H. LeMay has written the TP5 version of QWIK.  He 
  197.    can be contacted on the Borland Forum by typing GO BPROGA from the 
  198.    CompuServe main menu.  You will enter the Forum for Turbo Pascal.  You can 
  199.    contact Jim with his PPN number of 76011,217.  Messages can also be left 
  200.    through EasyPlex.
  201.  
  202.    Telephone - Jim can also be reached by phone at (817) 735-4833 on weekdays 
  203.    and Saturday from 9:00 a.m. to 8:00 p.m CST.
  204.  
  205.    The Eagle BBS - After 01-10-89, you can also contact us on our 24-hour BBS 
  206.    at (214) 539-9878, 1200 N81.
  207.  
  208.    Mail - For registration or problems, please write:
  209.  
  210.        Eagle Performance Software
  211.        TP products
  212.        P.O. Box 122237
  213.        Ft. Worth, TX  76121-2237
  214.  
  215.    In your written request for resolving problems, be sure to include:
  216.  
  217.      . A 5 1/4 inch diskette of compilable source code of the problem.
  218.      . The Eagle product and version number.
  219.      . The computer make and model.
  220.      . The type of video card, video monitor and keyboard.
  221.  
  222.  
  223.  
  224.    Chapter 1, Introduction                                             Page 4
  225.    QWIK Screen Utilities                             User's Guide, Version 5.x
  226.  
  227.  
  228.    For identical Turbo C products, write:
  229.  
  230.        Eagle Performance Software
  231.        TC products
  232.        P.O. Box 292786
  233.        Lewisville, TX  75029-2786
  234.  
  235.    Or, contact Jim Gallagher at (214)-539-7855
  236.  
  237.    ASP
  238.  
  239.    QWIK is a Shareware program conforming to the standards of the Association 
  240.    of Shareware Professionals (ASP).  You can get more information about ASP 
  241.    by writing to:
  242.     
  243.      Association of Shareware Professionals
  244.      325 118th Ave. S.E., Suite 200
  245.      Bellevue, WA  98005.
  246.  
  247.  
  248.  
  249.  
  250.  
  251.  
  252.  
  253.  
  254.  
  255.  
  256.  
  257.  
  258.  
  259.  
  260.  
  261.  
  262.  
  263.  
  264.  
  265.  
  266.  
  267.  
  268.  
  269.  
  270.  
  271.  
  272.  
  273.  
  274.  
  275.  
  276.  
  277.  
  278.  
  279.  
  280.  
  281.  
  282.  
  283.  
  284.  
  285.    Chapter 1, Introduction                                             Page 5
  286.    QWIK Screen Utilities                             User's Guide, Version 5.x
  287.  
  288.  
  289.    2.  G E T T I N G   S T A R T E D
  290.  
  291.    This section will acquaint you with the files on disk and show you a 
  292.    brief demonstration.  You will also run your first program with QWIK and 
  293.    then become familiar with all of the utilities.
  294.  
  295.  
  296.    DISTRIBUTION FILES
  297.  
  298.    In this version, QWIK5X.ARC contains:
  299.  
  300.      Qwik5x  .tpu:  Compiled unit of 2000 lines of assembly for TP5.
  301.      Qwik5x  .pas:  Source code for QWIK5X.TPU.  (MASM source code 
  302.                     and object files are not included.)
  303.      Qwik5x  .doc:  This document - a user's guide to QWIK.
  304.      QwikDemo.pas:  A demonstration program showing the features and 
  305.                     speed of all procedures and is written primarily 
  306.                     for color cards, but also works on mono cards.
  307.      QwikRef .doc:  QWIK Reference Guide document covering each 
  308.                     procedure and variable in detail.
  309.      Qinitest.pas:  A program that verifies the equipment detected by 
  310.                     the Qinit procedure.
  311.      Qbench  .pas:  A timing program that shows "screens/second" for 
  312.                     typical QWIK procedures.
  313.      Strs    .pas:  Supplementary unit for number to string 
  314.                     conversions.
  315.      TimerD12.inc:  Include file to measure elapsed time.
  316.      License .arc:  ARC file containing license agreements.
  317.  
  318.  
  319.    DEMONSTRATION
  320.  
  321.    To get an overview of the speed and features of QWIK, let's run a 
  322.    demonstration program that came with the utilities.  Do the following 
  323.    steps.
  324.  
  325.      1. Copy QWIK5X.TPU to QWIK.TPU for TP5.
  326.      2. Make, compile and run QWIKDEMO.PAS to get a feel for 
  327.         features and speed.  
  328.      3. Press return when the screen prompts you to continue with 
  329.         "... press any key".
  330.      4. Before running QINITEST.PAS, read the source code header 
  331.         to see if you want to test for a computer submodel ID.
  332.  
  333.  
  334.    SIMPLE PROGRAMMING
  335.  
  336.    First Program - Let's write a short program to see how simple it is to 
  337.    write with QWIK.  While in the TP editor, enter the following code:
  338.  
  339.      uses Crt,Qwik;
  340.      begin
  341.        TextAttr := Yellow+BlackBG;
  342.        ClrScr;
  343.        Qwrite (5, 1,Yellow+BlueBG,'QWIK writing');
  344.  
  345.  
  346.    Chapter 2, Getting Started                                          Page 6
  347.    QWIK Screen Utilities                             User's Guide, Version 5.x
  348.  
  349.  
  350.        Qwrite (5,13,Yellow+BlueBG,' is easy!');
  351.      end.
  352.  
  353.    Assuming you have already copied QWIK5X.TPU to QWIK.TPU, compile and run 
  354.    the code.  You can then see the text "QWIK writing is easy!" starting on 
  355.    row 5, column 1.  On color monitors, the text is a yellow foreground with a 
  356.    blue background while monochrome monitors show high intensity on black.
  357.  
  358.    Row/Col vs. X/Y - You probably noticed that the row parameter is first and 
  359.    the column parameter is second.  Since QWIK is entirely for text modes, it 
  360.    is more intuitive to specify the row first and the column second just like 
  361.    any word processor.  The X/Y scheme is better suited for graphics.
  362.  
  363.    Attributes - Notice that our example uses the constant "BlueBG".  QWIK 
  364.    provides eight convenient background color constants to use along with 
  365.    Turbo's 16 foreground colors.  The same names are used, but the "BG" suffix 
  366.    is added: 
  367.  
  368.       BlackBG       RedBG
  369.       BlueBG        MagentaBG
  370.       GreenBG       BrownBG
  371.       CyanBG        LightGrayBG
  372.  
  373.    These allow QWIK to make the most of Turbo's constant folding.  By simply 
  374.    adding the foreground and background constants together, the compiler saves 
  375.    the result as a single word.  And, by simply reading the Qwrite statement, 
  376.    what you see is what you get (WYSIWYG). 
  377.  
  378.    Readable Code - As an added benefit, QWIK was designed with human factors 
  379.    in mind and was made so that it is very easy to read the code you create.  
  380.    With the row, column, and attribute parameters first and the string last, 
  381.    you can see that the two Qwrite statements were easily aligned.  WYSIWYG to 
  382.    the rescue again!
  383.  
  384.    Chaining - Notice that we had to calculate the string length of "QWIK 
  385.    writing" before we could locate the string " is easy".  Let's modify the 
  386.    last statement to indeed make it easier to locate the last string:
  387.  
  388.      uses Crt,Qwik;
  389.      begin
  390.        TextAttr := Yellow+BlackBG;
  391.        ClrScr;
  392.        Qwrite (5, 1,Yellow+BlueBG,'QWIK writing');
  393.        QwriteEos   (Yellow+BlueBG,' is easy!');
  394.      end.
  395.  
  396.    Now that was really easy!  How did QwriteEos know where to write?  QWIK 
  397.    internally keeps track of an End-Of-String (EOS) marker so that any 
  398.    subsequent "Eos" procedure like QwriteEos will chain the next string right 
  399.    there - no rows or columns to calculate!  And you can chain as many as you 
  400.    want on to any other QWIK procedure.
  401.  
  402.    Same Attribute - But suppose we did not want to change the attribute that 
  403.    was already on the screen and don't even know what it is.  How is that 
  404.    done?  Just modify the attributes to the following:
  405.  
  406.  
  407.    Chapter 2, Getting Started                                          Page 7
  408.    QWIK Screen Utilities                             User's Guide, Version 5.x
  409.  
  410.  
  411.  
  412.      uses Crt,Qwik;
  413.      begin
  414.        TextAttr := LightGray+BlackBG;
  415.        ClrScr;
  416.        Qwrite (5, 1,SameAttr,'QWIK writing');
  417.        QwriteEos   (SameAttr,' is easy!');
  418.      end.
  419.  
  420.    The special constant SameAttr (which is negative) tells QWIK to simply 
  421.    enter the text on the screen without changing the attribute.  The result of 
  422.    the program would show the text with LightGray on Black attributes.  This    
  423.    special constant works on all QWIK utilities.  When assigned to a variable, 
  424.    the attribute can even be switched at run time.
  425.  
  426.    Centering - Rather than having the text left justified, let's center the 
  427.    text on the screen by modifying a portion of the code:
  428.  
  429.      ...
  430.        ClrScr;
  431.        QwriteC (5, 1,80,SameAttr,'QWIK writing is easy!');
  432.      end.
  433.  
  434.    This will place the text on row 5 centered between columns 1 and 80 which 
  435.    is perfect for an 80 column text mode.  But what if other text or column 
  436.    modes are used?  How can we ensure that it is always centered?  Only one 
  437.    simple change is needed:
  438.  
  439.      ...
  440.        ClrScr;
  441.        QwriteC (5, 1,CRTcols,SameAttr,'QWIK writing is easy!');
  442.      end.
  443.  
  444.    The variable CRTcols always has the value of the column width that is 
  445.    currently being used.  How does it know?  QWIK is initialized at startup by 
  446.    executing a procedure called Qinit.  It detects a host of information about 
  447.    your video configuration, everything from the type of video card you are 
  448.    using to the shape of the cursor being used.  You can see a list of all 
  449.    these variables available for your use in QWIKREF.DOC.
  450.  
  451.  
  452.    PROCEDURES AND FUNCTIONS
  453.  
  454.    Now that you have a basic idea of what QWIK can do, let's make a brief 
  455.    survey of all the utilities in QWIK.TPU to just know what is available:
  456.  
  457.      One initializing procedure:
  458.  
  459.          Qinit       - Initializing procedure executed by QWIK5X.TPU which 
  460.                        sets the global variables for the QWIK procedures.  
  461.                        It should be executed again after a change from one 
  462.                        text mode to another.
  463.  
  464.      Three quick direct screen writing procedures, all work with or 
  465.      without attribute change:
  466.  
  467.  
  468.    Chapter 2, Getting Started                                          Page 8
  469.    QWIK Screen Utilities                             User's Guide, Version 5.x
  470.  
  471.  
  472.  
  473.          Qwrite      - For any type string or character (char).
  474.          QwriteC     - For any type string or char; self-centering.
  475.          QwriteA     - For any type variable, arrays or substrings. 
  476.  
  477.      Four quick direct screen filling procedures in Rows-by-Cols block 
  478.      parameters:
  479.  
  480.         Qfill        - Repetitive filling with the same character; with or
  481.                        without attribute change.
  482.         QfillC       - Same as Qfill, but self-centering.
  483.         Qattr        - Repetitive filling with an attribute only.
  484.         QattrC       - Same as Qattr, but self-centering. 
  485.  
  486.      Two quick screen storing procedures:
  487.  
  488.         QstoreToMem  - Saves a Rows-by-Cols block to memory.
  489.         QstoreToScr  - Restores a Rows-by-Cols block to any screen page.
  490.  
  491.      Two quick screen storing procedures for copying blocks between a 
  492.      screen (Scr) and a virtual screen (Vscr - a screen in memory):
  493.  
  494.         QScrToVscr   - Copies a Rows-by-Cols block from QWIK screen to 
  495.                        virtual screen.
  496.         QVscrToScr   - Restores a Rows-by-Cols block from a virtual screen 
  497.                        to the QWIK screen.
  498.  
  499.      Three quick screen reading functions for reading data from any 
  500.      screen:
  501.  
  502.          QreadStr    - Reads a string of text.
  503.          QreadChar   - Reads a single character.
  504.          QreadAttr   - Reads an attribute.
  505.  
  506.      Two quick scrolling procedures work on any video page and also  
  507.      virtual screens without flicker or snow:
  508.  
  509.          QscrollUp   - Scroll affected rows-by-cols block up.
  510.          QscrollDown - Scroll affected rows-by-cols block down.
  511.  
  512.      Two quick video page changing procedures:
  513.  
  514.          QviewPage   - Changes the page to be displayed - up to 8!
  515.          QwritePage  - Sets the page on which the QWIK procedures are 
  516.                        writing.  You don't have to write just on the 
  517.                        displayed page!
  518.  
  519.      Three quick cursor procedures and functions which work on any video 
  520.      page.  They now work on the page being written rather than viewed:
  521.  
  522.          GotoRC      - Move cursor to absolute row and column coordinates 
  523.                        rather than relative to a window.
  524.          WhereR      - Returns absolute cursor row.
  525.          WhereC      - Returns absolute cursor column. 
  526.  
  527.  
  528.  
  529.    Chapter 2, Getting Started                                          Page 9
  530.    QWIK Screen Utilities                             User's Guide, Version 5.x
  531.  
  532.  
  533.      Eight quick EOS (End-Of-String) marker procedures and functions that 
  534.      alter its position and/or the cursor.  The marker can be moved on the 
  535.      CRT and virtual screens, while the cursor movement is only on the 
  536.      page being written:
  537.  
  538.           GotoEos      - Moves cursor to EOS marker (like TP write).
  539.           EosR         - Returns absolute row of EOS marker.
  540.           EosC         - Returns absolute col of EOS marker.
  541.           EosToRC      - Sets EOS to a given row and column.
  542.           EosToRCrel   - Relatively shifts EOS by a number of rows and 
  543.                          columns, and can be negative or positive.
  544.           EosToCursor  - Matches EOS to the cursor position.
  545.           EosLn        - Moves EOS to column 1 of the next row.
  546.           QEosLn       - Like EosLn, but scrolls up if past last row.
  547.  
  548.      Three cursor routines alter the cursor mode:
  549.  
  550.          GetCursor    - Get current cursor mode from low memory.
  551.          SetCursor    - Sets new cursor mode. 
  552.          ModCursor    - Modifies cursor mode to on, off or erratic
  553.                         blink saving current scan lines.
  554.  
  555.      Four quick EOS writing procedures that chain write at the EOS marker: 
  556.  
  557.          QwriteEos    - like Qwrite.
  558.          QwriteEosA   - like QwriteA.
  559.          QfillEos     - like Qfill.
  560.          QattrEos     - like Qattr.
  561.  
  562.      A Submodel identification routine:
  563.  
  564.          GetSubModelID - Optional procedure to find IBM submodel ID.
  565.  
  566.      Five string functions that convert integers and reals to strings by 
  567.      using the supplementary STRS unit:
  568.  
  569.          StrL   - converts LongInt to string
  570.          StrLF  - converts LongInt to string in a fixed Field
  571.          StrR   - converts Real to string
  572.          StrRF  - converts Real to string in a fixed Field
  573.          StrRFD - converts Real to string in a fixed Field with a 
  574.                   specified number of Decimals
  575.  
  576.    For a full description of each utility with its parameters, please refer to 
  577.    QWIKREF.DOC for a summary of details and examples.
  578.  
  579.  
  580.  
  581.  
  582.  
  583.  
  584.  
  585.  
  586.  
  587.  
  588.  
  589.  
  590.    Chapter 2, Getting Started                                          Page 10
  591.    QWIK Screen Utilities                             User's Guide, Version 5.x
  592.  
  593.  
  594.    3.  B A S I C   T E C H N I Q U E S
  595.  
  596.  
  597.    NUMBER TO STRING CONVERSION
  598.  
  599.    Str Procedure - TP5 handily converts numbers into strings with the Str 
  600.    procedure.  For example:
  601.  
  602.      var MyNumber: integer;
  603.          MyString: string;
  604.      begin
  605.        Str (MyNumber:7,MyString);
  606.        Qwrite ( 1, 1,SameAttr,MyString);
  607.      end.
  608.  
  609.    But this means that a data area must be reserved and the code isn't as 
  610.    readable as it could be.
  611.  
  612.    Str Functions - Instead, QWIK and the supplementary STRS unit let you use a 
  613.    function form of Str:
  614.  
  615.      uses Qwik, Strs;
  616.      var MyNumber: integer;
  617.      begin
  618.        Qwrite ( 1, 1,SameAttr,StrLF(MyNumber,7));
  619.      end.
  620.  
  621.    Just like WriteLn, this lets the number remain in the Qwrite statement.  
  622.    There are five functions in the STRS unit and they can be used just like 
  623.    any other function:
  624.  
  625.      StrL   - converts LongInt to string
  626.      StrLF  - converts LongInt to string in a fixed Field
  627.      StrR   - converts Real to string
  628.      StrRF  - converts Real to string in a fixed Field
  629.      StrRFD - converts Real to string in a fixed Field with a specified 
  630.               number of Decimals
  631.  
  632.    The suffixes mean:
  633.  
  634.      L - LongInt, but any scalar will work
  635.      R - Real
  636.      F - Field width that is right justified format
  637.      D - Number of decimals in the format
  638.  
  639.    The Str* functions actually use the Str procedure from TP5 to do the 
  640.    conversion.  But with an InLine code trick, functions were created that 
  641.    don't recopy the string for the greatest speed.  The code useage is 
  642.    also reduced.
  643.  
  644.  
  645.    CURSOR MODE ROUTINES
  646.  
  647.    Three Routines - If you have ever struggled with controlling the shape of 
  648.    the cursor, your life is about to be made easier.  With just three 
  649.  
  650.  
  651.    Chapter 3, Basic Techniques                                         Page 11
  652.    QWIK Screen Utilities                             User's Guide, Version 5.x
  653.  
  654.  
  655.    routines, SetCursor, GetCursor, and ModCursor, you can consistently and 
  656.    reliably control the cursor mode (shape and visibility) on any video card!
  657.  
  658.    Four Standard Modes - To make it even easier, four standard cursor mode 
  659.    variables are initialized at startup to fit the exact requirements of the 
  660.    detected video card.  They are:
  661.  
  662.      CursorUnderline - The standard underline cursor.
  663.      CursorHalfBlock - The half block shape usually used for insert 
  664.                        editing.
  665.      CursorBlock     - An easy to find full cell cursor.
  666.      CursorInitial   - The mode detected at start up.
  667.  
  668.    So, if we wanted a full block cursor, only one line of code is needed:
  669.  
  670.      SetCursor (CursorBlock);
  671.  
  672.    And that's it!  There's nothing else to figure out - even if you are using 
  673.    something like 43-row mode on an EGA card.  When ending your programs, you 
  674.    can get back to the original cursor mode by using:
  675.  
  676.      SetCursor (CursorInitial);
  677.  
  678.    Hidden Cursor - Many programs need to hide the cursor altogether.  This can 
  679.    be done with ModCursor:
  680.  
  681.      ModCursor (CursorOff);
  682.  
  683.    Why use ModCursor instead of SetCursor?  ModCursor leaves the shape of the 
  684.    cursor alone, and only alters bits 13 and 14 of the cursor mode to turn it 
  685.    on or off.  In fact there are three constants that are useful with 
  686.    ModCursor:
  687.  
  688.      CursorOff   ($2000) - To turn the cursor off.
  689.      CursorOn    ($0000) - To turn the cursor back on with the same shape.
  690.      CursorBlink ($6000) - To create erratic blinking on MDA/CGA.  (On 
  691.                            EGA/VGA, it turns the cursor off.)
  692.  
  693.    Using your imagination, you can also mix and match the constants and 
  694.    variables by logically summing them.  Let's say we want to change the shape 
  695.    of the cursor to a block while it is still turned off:
  696.  
  697.      SetCursor (CursorBlock or CursorOff);
  698.  
  699.    So, the next time ModCursor(CursorOn) is used, the cursor will be a full 
  700.    block.  As a suggestion for terminating your program, be sure to restore 
  701.    the cursor in your exit procedure with: 
  702.  
  703.      SetCursor (CursorInitial);
  704.  
  705.    GetCursor - This function simply returns the current cursor mode value 
  706.    stored in low memory allowing you to save it for later use.
  707.  
  708.  
  709.  
  710.  
  711.  
  712.    Chapter 3, Basic Techniques                                         Page 12
  713.    QWIK Screen Utilities                             User's Guide, Version 5.x
  714.  
  715.  
  716.    CURSOR LOCATION ROUTINES
  717.  
  718.    QWIK has three routines that complement the CRT unit - GotoRC, WhereR, and 
  719.    WhereC.  They correspond with the familiar GotoXY, WhereX, and WhereY.  
  720.    However, there are some important differences: 
  721.  
  722.      . The QWIK routines are absolute to the screen and are not restricted 
  723.        by the Turbo window.
  724.      . The suffixes "R" and "C" mean row and column, so the parameters of      
  725.        GotoRC are reversed from GotoXY.
  726.      . The QWIK routines will also work on any video page.  This is 
  727.        explained in the Advanced Techniques section later.
  728.  
  729.    This is not the only way to move the cursor.  The EOS marker is also a very 
  730.    powerful aid as you will see in the next topic.
  731.  
  732.  
  733.    EOS MARKER
  734.  
  735.    Invisible Alternate Cursor - From the examples in the Simple Programming 
  736.    topic, we found that we could easily chain two strings together using the 
  737.    EOS marker.  In fact, this marker is so versatile, the EOS marker utilities 
  738.    can be made interchangeable with the cursor, but much faster.  You could 
  739.    think of it as an alternate cursor that is invisible.
  740.  
  741.    Keeping Track - Any time a QWIK writing procedure is used, the EOS marker 
  742.    is updated.  It is actually saved as the global variable QEosOfs.  
  743.    Technically, the value is the offset from the screen base and is a 0-based 
  744.    byte count.  For example, if the following procedure was executed:
  745.  
  746.      Qwrite (6,5,Yellow,'Important Data');
  747.  
  748.    the EOS would be at row 6, column 19, right after the word "Data".  The 
  749.    value of QEosOfs on an 80 column screen would be:
  750.  
  751.      QEosOfs = ((Row-1)*CRTcols + (Col-1)) * 2 = 836
  752.  
  753.    QWIK does not need to calculate this value, but simply saves it after 
  754.    writing, so it is very efficient.  From the overview, you are already aware 
  755.    of the four routines that will start writing at this marker - QwriteEos, 
  756.    QwriteEosA, QfillEos, and QattrEos.  But what about changing the location 
  757.    of the marker itself?  Keep reading.
  758.  
  759.    Moving the Marker - QWIK has four routines that will manually move the EOS 
  760.    marker:
  761.  
  762.      EosToRC      - Sets EOS to a given row and column.
  763.      EosToRCrel   - Relatively shifts EOS by a number of rows and 
  764.                     columns, and can be negative or positive.
  765.      EosLn        - Moves EOS to column 1 of the next row.
  766.      QEosLn       - Like EosLn, but scrolls up if past last row.
  767.  
  768.    The basic procedure EosToRC moves the EOS marker exactly like GotoRC does 
  769.    for the cursor.  But there are also several ways to move the marker 
  770.    relatively.  Let's test a short program:
  771.  
  772.  
  773.    Chapter 3, Basic Techniques                                         Page 13
  774.    QWIK Screen Utilities                             User's Guide, Version 5.x
  775.  
  776.  
  777.  
  778.      uses Crt,Qwik;
  779.      begin
  780.        TextAttr := Yellow;
  781.        ClrScr;
  782.        Qwrite     ( 1, 1,Yellow+BlueBG,'First  Row ');
  783.        EosLn;                                           { Jump to (2,1) }
  784.        QwriteEos        (Yellow+BlueBG,'Second Row ');
  785.        EosToRC    ( 3, 1);                              { Jump to (3,1) }
  786.        QwriteEos        (Yellow+BlueBG,'Third  Row ');
  787.        EosToRCrel ( 1,-4);                              { Jump to (4,8) }
  788.        QwriteEos        (Yellow+BlueBG,       'etc.');
  789.        EosToRC    (succ(EosR),8);                       { Jump to (5,8) }
  790.        QwriteEos        (Yellow+BlueBG,       'etc.');
  791.      end.
  792.  
  793.    Compile and run the program.  You should see "Row" and "etc." all aligned 
  794.    in one column.  So, you can see that there are several simple ways to move 
  795.    the marker!
  796.  
  797.    EOS and the Cursor - You can also interface the EOS marker and the cursor 
  798.    with two procedures:
  799.  
  800.      GotoEos      - Moves cursor to match the EOS marker.
  801.      EosToCursor  - Sets the EOS marker to match the cursor position.
  802.  
  803.    It can't get any simpler than that!  Now you can see that:
  804.  
  805.      Qwrite (1,1,Yellow,'Test Line');
  806.      GotoEos;
  807.  
  808.    and,
  809.      
  810.      TextAttr := Yellow;
  811.      GotoXY (1,1);
  812.      Write ('Test Line');
  813.  
  814.    produce identical results.  But QWIK is much faster!
  815.  
  816.  
  817.    SCROLLING
  818.  
  819.    Improved Control - With the CRT unit, you can only control the full screen 
  820.    size with WriteLn.  But with the two QWIK routines, QscrollUp and 
  821.    QscrollDown, you can define any area to be scrolled: 
  822.  
  823.       QscrollUp ( 2, 2,CRTrows-2,CRTcols-2,MyAttr);
  824.  
  825.    This example scrolls a portion of the screen starting at (2,2) leaving a 
  826.    one character border.  In a 25x80 text mode, it clears row 24 from column 2 
  827.    to 79.  In addition, the cleared row attribute is MyAttr.
  828.  
  829.    Improved Performance - With QscrollDown and QscrollUp (called Qscroll* for 
  830.    brevity), your programs can overcome the BIOS problems on many machines.   
  831.    Transparent to you, these procedures work on all cards and machines without 
  832.  
  833.  
  834.    Chapter 3, Basic Techniques                                         Page 14
  835.    QWIK Screen Utilities                             User's Guide, Version 5.x
  836.  
  837.  
  838.    flicker or snow and operate at three speeds: 
  839.  
  840.      Maximum  - for video cards without snow
  841.      Fast CGA - for CGA cards on 80286 machines or better
  842.      Slow CGA - for CGA cards on 8086/8088 machines
  843.  
  844.    Qinit detects the CPU ID and video card to select the fastest algorithm.  
  845.    All speeds use 16-bit transfers rather than 8-bit.  So, you can be assured 
  846.    of the highest performance.
  847.  
  848.    Cursor Location - These routines do not move the cursor.  However, EOS is 
  849.    pointing to the first column of the blank line and GotoEos will move the 
  850.    cursor there if needed.
  851.  
  852.    QEosLn - This procedure is another alternative to full screen scrolling.  
  853.    It has the same function as EosLn, but will additionally scroll the screen 
  854.    up if the EOS marker is past the last row.  Then it simply calls QscrollUp.  
  855.    The attribute of the cleared row is the global variable ScrollAttr.  You 
  856.    must set this prior to using QEosLn.
  857.  
  858.  
  859.    POP-UP WINDOWS
  860.  
  861.    QWIK has the basic tools to create and remove pop-up windows.  Let's try to 
  862.    create one.  While in the TP editor, enter the following code:
  863.  
  864.      uses Crt,Qwik;
  865.      var 
  866.        MyWindow,MyUnderlay: array[1..250] of word;
  867.      begin
  868.        { -- Fill the screen with a hatch character. -- }
  869.        Qfill ( 1, 1,CRTrows,CRTcols,LightGray+BlackBG,#176);  
  870.        { -- Create a pop-up window.-- }
  871.        QstoreToMem ( 5,12,10,25,MyUnderlay);  { Save area to be covered }
  872.        Qfill       ( 5,12,10,25,Black+LightGray,' ');  { Clear the area }
  873.        QwriteC (9,12,36,SameAttr,'Pop-Up Window');     { Label window   }
  874.        delay (1000);                                   { Wait a sec     }
  875.        QstoreToMem ( 5,12,10,25,MyWindow);             { Save a copy    }
  876.        QstoreToScr ( 5,12,10,25,MyUnderlay);           { Restore screen }
  877.        { -- Move window some where else. -- }
  878.        QstoreToMem ( 8,25,10,25,MyUnderlay);  { Save area to be covered }
  879.        QstoreToScr ( 8,25,10,25,MyWindow);             { Move window    }
  880.        delay (1000);                                   { Wait a sec     }
  881.        { -- Remove window. -- }
  882.        QstoreToScr ( 8,25,10,25,MyUnderlay);           { Restore screen }
  883.      end.
  884.  
  885.    Compile and run the code.  You will see a 10 row by 25 column window 
  886.    located at (5,12) which is row 5, column 12 .  After one second, it will be 
  887.    moved to (8,25).  Then after another second, it is removed from the screen.  
  888.    We did a lot of work with very little code!
  889.  
  890.    Rows-by-Cols - QstoreToScr and QstoreToMem are screen saving and restoring 
  891.    procedures that conveniently work in row-by-column blocks.  They 
  892.    accommodate any column mode, so there is no need to be concerned about 
  893.  
  894.  
  895.    Chapter 3, Basic Techniques                                         Page 15
  896.    QWIK Screen Utilities                             User's Guide, Version 5.x
  897.  
  898.  
  899.    screen width.
  900.  
  901.    Memory Requirements - Notice that QstoreToMem wrote the data direct to 
  902.    memory in MyWindow.  It is important that the memory allocated to that 
  903.    variable is correct to prevent it from overwriting any other variables.  
  904.    The array size chosen was a 250 word array which is a perfect fit since one 
  905.    word is needed for each character and attribute on the screen.  If you 
  906.    prefer, the heap can also be used such as:
  907.  
  908.      var MyUnderlay: pointer;
  909.      begin
  910.        GetMem (MyUnderlay,500);
  911.        QstoreToMem ( 5,12,10,25,MyUnderlay^);  
  912.        { ... }
  913.        FreeMem (MyUnderlay,500);
  914.      end.
  915.  
  916.  
  917.  
  918.  
  919.  
  920.  
  921.  
  922.  
  923.  
  924.  
  925.  
  926.  
  927.  
  928.  
  929.  
  930.  
  931.  
  932.  
  933.  
  934.  
  935.  
  936.  
  937.  
  938.  
  939.  
  940.  
  941.  
  942.  
  943.  
  944.  
  945.  
  946.  
  947.  
  948.  
  949.  
  950.  
  951.  
  952.  
  953.  
  954.  
  955.  
  956.    Chapter 3, Basic Techniques                                         Page 16
  957.    QWIK Screen Utilities                             User's Guide, Version 5.x
  958.  
  959.  
  960.    4.  A D V A N C E D   T E C H N I Q U E S
  961.  
  962.    This section will acquaint you with the powerful virtual screen writing 
  963.    features already built into QWIK.  You will also find out easy it is to 
  964.    work on multiple video pages and how to accommodate video mode changes.
  965.  
  966.  
  967.    VIRTUAL SCREENS
  968.  
  969.    This topic will show you how to create and use powerful virtual screens.
  970.  
  971.    Virtual Screen - Just what is a virtual screen?  It is a screen maintained 
  972.    in RAM of any dimensions that can be reproduced on the CRT in full or in 
  973.    part.  The advantages are:
  974.  
  975.      . Variable row-by-column screen 
  976.      . Large video buffer up to 64k
  977.      . High speed in RAM
  978.      . Unlimited number of screens
  979.  
  980.    Screen Record - QWIK uses seven variables to define any screen.  At start 
  981.    up, QWIK initializes them to the video system detected:
  982.  
  983.      CRTrows  - Number of rows
  984.      CRTcols  - Number of columns
  985.      CRTsize  - Byte allocation for screen
  986.      Qsnow    - True if snow checking needed
  987.      QEosOfs  - EOS offset
  988.      QScrOfs  - Screen offset
  989.      QScrSeg  - Screen segment
  990.  
  991.    To make data access even easier, all these variables are contained in the 
  992.    record QScrRec of VScrRecType.  In addition, QScrPtr is absolute to QScrOfs 
  993.    and QScrSeg.  This gives QWIK a true far pointer, so screens can be 
  994.    anywhere in memory and not just paragraph aligned!
  995.  
  996.    Creating Virtual Screens - In three easy steps, you can easily create a 
  997.    virtual screen:
  998.  
  999.      1. Allocate memory for the screen.
  1000.      2. Save the current screen record.
  1001.      3. Modify the screen record for the virtual screen.
  1002.  
  1003.    Let's write some code that does just that:
  1004.  
  1005.      uses Qwik;
  1006.      var  CRTrec,VScrRec: VScrRecType;
  1007.      begin
  1008.        with VScrRec do             { create specs for virtual screen }
  1009.          begin
  1010.            Vrows := 80;            { Let's choose 80 rows }
  1011.            Vcols := 100;           { Let's choose 100 columns }
  1012.            Vsize := Vrows * Vcols shl 1;
  1013.            Vsnow := false;         { Can always be false }
  1014.            VEosOfs := 0;           { Be safe and start at the base }
  1015.  
  1016.  
  1017.    Chapter 4, Advanced Techniques                                      Page 17
  1018.    QWIK Screen Utilities                             User's Guide, Version 5.x
  1019.  
  1020.  
  1021.            GetMem (VScrPtr,Vsize); { Allocate heap space }
  1022.          end;
  1023.        CRTrec  := QScrRec;         { Save CRT specs     }
  1024.        QScrRec := VScrRec;         { Set virtual specs  }
  1025.        { ... }                     { Write to the virtual screen }
  1026.        QScrRec := CRTrec;          { Restore CRT specs when done! }
  1027.      end.
  1028.  
  1029.    Now, when you use any QWIK routine, they can be directed to the virtual 
  1030.    screen - writing, reading, scrolling, wrapping, and everything you would 
  1031.    expect.  Qsnow can always be false when writing to virtual screens since 
  1032.    RAM is used and not video card memory.
  1033.  
  1034.    Cursor Control - One thing not available to virtual screens is cursor 
  1035.    movement, because the cursor location is reserved by DOS for just video 
  1036.    pages.  That means there is no cursor available for virtual screens.  So, 
  1037.    how can we get around this?  The EOS marker comes to the rescue as an 
  1038.    indispensable cursor!  All EOS routines can still be used as before.
  1039.  
  1040.    Taking a Peek - At some time, we will need to take a look at all or a 
  1041.    portion of the virtual screen by copying it to the CRT.  Two inter-screen 
  1042.    procedures do this by blocks at high speed - QScrToVscr and QVscrToScr.  
  1043.    Here are the parameters of QVscrToScr: 
  1044.  
  1045.      QVscrToScr (Row,Col,Rows,Cols,Vrow,Vcol,Vwidth,VScrPtr);
  1046.  
  1047.    Just like QstoreToScr, Row, Col, Rows, and Cols describe the position and 
  1048.    size on the screen (Scr).  This screen is specified by QScrRec which is 
  1049.    usually the CRT.  VScrPtr points to the virtual screen (Vscr).  Now, where 
  1050.    is the same size block on Vscr?  It's at Vrow and Vcol.  But the Vscr may 
  1051.    have a different column width than CRTcols.  So you specify that with 
  1052.    Vwidth.  Only the Scr side checks for possible snow.  These procedures are 
  1053.    extremely fast making virtual screens very practical.  See QScrToVscr and 
  1054.    QVscrToScr in QWIKREF.DOC for more examples.
  1055.  
  1056.    Multiple Virtual Screens - By changing QScrRec, you can even copy blocks 
  1057.    from one virtual screen to another!  These routines do not affect QEosOfs.
  1058.  
  1059.  
  1060.    VIDEO PAGES
  1061.  
  1062.    Multi-page Cards - TP5 procedures such as Write, Window, and GotoXY are 
  1063.    dedicated to just page 0, but many video cards have more than one page.  If 
  1064.    you have a CGA or better, you already have memory on your card for 4 to 8 
  1065.    pages.  Since the BIOS recognizes them as well, QWIK gives you access to 
  1066.    these extra pages.
  1067.  
  1068.    Page Control - QwritePage and QviewPage give you the power to use QWIK on 
  1069.    all video pages and display which ever you choose.  On a multiple-video 
  1070.    page card like CGA, you can simply code:
  1071.  
  1072.      QwritePage (MyPage);
  1073.  
  1074.    to make all QWIK routines be directed to your selected video page even 
  1075.    though you could be viewing another page.  To view a page, you can in turn 
  1076.  
  1077.  
  1078.    Chapter 4, Advanced Techniques                                      Page 18
  1079.    QWIK Screen Utilities                             User's Guide, Version 5.x
  1080.  
  1081.  
  1082.    simply code: 
  1083.  
  1084.      QviewPage (MyPage);
  1085.  
  1086.    Tips About Pages - Here are some tips to keep in mind when using several 
  1087.    video pages:
  1088.  
  1089.      . The highest valid video page is detected by Qinit and saved in the 
  1090.        variable MaxPage.
  1091.      . Invalid page parameters are just ignored.
  1092.      . The BIOS reserves a separate cursor location for each of up to 8 
  1093.        video pages.
  1094.      . There is only one possible cursor mode which is always displayed on 
  1095.        the CRT.
  1096.      . The cursor location routines operate on the page being written 
  1097.        rather than viewed.
  1098.      . The current video page viewed is found with VideoPage.
  1099.      . The current video page set by QwritePage is saved in QvideoPage.
  1100.      . Be sure to end your programs with "QviewPage (0);". 
  1101.  
  1102.  
  1103.    VIDEO MODES    
  1104.  
  1105.    CRT Unit - If you intend to use the CRT unit with QWIK, it is best to place 
  1106.    the CRT unit first in the "USES" list.  When the CRT runs its 
  1107.    initialization code, it checks for the video mode to see if it is a valid 
  1108.    text mode (0..3,7).  If so, it remains in that mode.  If not, it is in a 
  1109.    graphics or extended column mode and is forced back into the