home *** CD-ROM | disk | FTP | other *** search
/ CD Actual 15 / CDACTUAL15.iso / cdactual / program / basic / QB4WIN30.ZIP / W30.DOC < prev    next >
Encoding:
Text File  |  1989-05-01  |  26.2 KB  |  564 lines

  1.         This is another (ho-hum) Quickbasic library, dealing almost
  2. exclusively with routines that print text.  Most such libraries are a
  3. series of short, pretty much independent calls.  This one is more
  4. integrated in that calls such as KLS, Prnt, Kolor and Lokate
  5. share data, as do OpenW, FillW, and CloseLastW and others.  It gives you
  6. the ability to set the display to any of the VGA text modes, print strings
  7. and numbers on 132 column displays, read and set the VGA color registers,
  8. in addition to the usual windows routines.
  9.  
  10.         Feel free to write if you think you have found a bug or
  11. the program doesn't work as expected.  You might first check for a newer
  12. version, and may also try leaving a message on the Odie link. New versions
  13. of QB4Win can usually be found on these BBS's:
  14. Exec-PC                         (414) - 964 - 5160
  15. The Utilities Exchange          (614) - 442 - 6695
  16. Jesse's Board                   (513) - 385 - 8512
  17. Greater Cincinnatti PC users    (513) - 221 - 7284
  18. Public Domain SIG               (619) - 749 - 2741
  19. Odie link                       (614) - 335 - 3972.
  20. ================================================================================
  21.  
  22.         Documentation for QBasic Windows Version 3.0  April 1989
  23.  
  24. The calls are listed in this file in alphabetical order, followed by
  25. the notes.
  26.  
  27. The documentation for W30.bas and most of the VGA routines is
  28. in W30.BAS in the sub W30DOC.
  29.  
  30. * denotes new or changed in this version
  31.  
  32.                         I.  Window Routines
  33.  
  34.         OpenW                   FillW                  *SetViewP
  35.         SaveW                   InitW                   SetViewW
  36.         CloseW                  DebugW
  37.         CloseLastW              DefBorder              *Dump2
  38.  
  39.  
  40.                         II. Print routines
  41.  
  42.         Printt                  PrintW                 *Lokate
  43.         Prnt                    PrntW                   Kolor
  44.        *PrntS                  *PrntUsingS             *KLS
  45.  
  46.  
  47.                        III. Misc
  48.         ScrollU                 ReadScreen              ChangeAttr
  49.         ScrollD                 Int3                    SwapAttr
  50.         ScrollL                *Int10                   CGA
  51.         ScrollR                *Adapter                 Monochrome
  52.                                *ReturnSegments
  53.  
  54.                        III. Notes
  55.  
  56.         Arrays                  Files                   Segments
  57.         Attributes              Lockups                 TR,LC,BR,RC
  58.         W30.DEC
  59.  
  60. ===========================================================================
  61.        If you will, let me know how successful this program has been.
  62.  
  63.                James A. Paisley
  64.                10690 Allen Rd NW
  65.                Washington C.H.,Oh 43160
  66.  
  67.        Name     _________________________________________
  68.  
  69.        Address __________________________________________
  70.  
  71.                __________________________________________
  72.  
  73.        I have version________3.0_____
  74.  
  75.  
  76.        Enclose $5 if you want the source code, about 3500 lines in assembler.
  77.  
  78. ===========================================================================
  79. Adapter (a%)
  80.         Pass an integer variable to this call to find what kind of video
  81. adapter is active.  I have not tested it with anything except a VGA.  A
  82. VGA will return a value of 3 even if it is emulating a CGA or EGA.
  83.         Return codes:
  84.                 0 - monochrome
  85.                 1 - CGA
  86.                 2 - EGA
  87.                 3 - VGA
  88. ===========================================================================
  89. CGA  ()
  90.         Changes the video segment to B800h for use with the
  91.         CGA, EGA or VGA.  This is the default value.
  92. ===========================================================================
  93. ChangeAttr  (attr)
  94.      Changes all the attributes on the screen to a given value.  Assumes
  95. the display is 25 x 80.
  96. ===========================================================================
  97. CloseLastW ()
  98. Closes the most recently opened window (created with OpenW or SaveW).
  99. The coordinates and segment of the last ten windows are saved on a
  100. revolving stack so it may be called up to ten times.  CloseW will bump
  101. the last one off the stack. OpenW and SaveW add one to the stack (even
  102. if the segment is 0). Call DebugW to view the stack.
  103. Example:
  104.        redim b(1000):
  105.        CALL SaveW(VARSEG(b(1)), 1, 1, 24, 80)
  106.        call OpenW(2,&h30,0,1,40,10,60)
  107.        call CloseLastW
  108.        call CloseLastW
  109. ===========================================================================
  110. CloseW (segment,TR,LC,BR,RC)
  111. Closes a window opened by either SaveW or OpenW.  The window may be
  112. moved or copied to a new location on the screen by changing the
  113. coordinates.
  114. ===========================================================================
  115. DebugW ()
  116.         Prints information about the current values for QB4Windows
  117.         parameters.
  118. ===========================================================================
  119. DefBorder(x$)
  120. Allows the user to define a new border.  X$ is a string of nine characters
  121. for the        top left corner
  122.                top row
  123.                top right corner
  124.                left side
  125.                middle
  126.                bottom left corner
  127.                bottom line
  128.                bottom right corner
  129.        DefBorder may also be used to fill an area of the screen with a
  130.        character. For example, to fill the entire screen with periods:
  131.                Call DefBorder (".........")
  132.                call OpenW(4,attribute,0,1,1,25,80)
  133.  
  134. ===========================================================================
  135. Dump2 (r, c, attr, border, NLines, Ncol, seg, offset, format, refreshRate)
  136.         Does a debug-style memory dump.  W30.BAS demonstrates this routine
  137. by using a sort of multi-tasking to do an X-RAY type dump of the keyboard
  138. buffer.
  139.         R & C   Start printing at this row and column
  140.         attr    defines the color
  141.         border  same as borders used by OpenW
  142.         NLines  # of lines to dump
  143.         Ncol    not used with this format
  144.         Seg     Segment to display
  145.         Offset  Offset to display
  146.         format  not used
  147.         rate    not used
  148. The Offset is an integer variable ( not BYVAL), and is changed after the
  149. call so you may scroll thru memory without redefining the offset.
  150. The call Refresh simply repeats the last call to dump2, but faster because
  151. no data is passed.
  152.         You should be able to display the memory dump on a second monitor
  153. by switching between the cga & vga video segments:
  154.         Call Mono: Call Refresh: Call CGA
  155. ===========================================================================
  156. FillW ( n , varptr(a$(L) )
  157.         Fills a window with strings from an array.
  158.         The coordinates used are those
  159. of the window most recently  opened with OpenW or SaveW.  The first n
  160. characters of each string are skipped, so increasing n has the effect of
  161. scrolling to the left. Increasing L has the effect of scrolling up.
  162. Example:       call OpenW(2,7,0,2,20,10,40)
  163.                redim a$(500)
  164.                [ assign strings to a$() ]
  165.                n=0:L=1
  166.                call FillW(n,varptr(a$(L))
  167.  
  168. The sub FILL in WDemo.bas demonstrates using FillW to view a file and
  169. the main menu uses it to fill a menu box.
  170. This will not work with an array of fixed length strings.
  171. ===========================================================================
  172. GScrollL8  (TR, LC, BR, RC)
  173. Scrolls left 8 pixels in graphics mode (screen 1 and screen 2).
  174. tr and br are numbers from 0 to 199
  175. lc and rc are from 0 to 639 and are rounded down to the nearest multiple of 8.
  176. there is no error checking, wierd values could make it hang
  177. not thoroughly tested
  178. ===========================================================================
  179. InitW  (RR%, CC%)
  180.         Resets all the parameters for windows to their default values.
  181.         This should be called at the beginning of a program.  If the
  182.         program is halted and run again, the defaults may be incorrect.
  183.         This call passes the integer variables RR and CC so that Lokate,
  184.         Prnt and PrntW can find them.
  185.         The call to InitW is included in W30.DEC.
  186. ===========================================================================
  187. int3 ()
  188.         calls interrupt 3
  189. ===========================================================================
  190. Int10   (ax%, bx%, cx%, dx%)
  191.         Copies DS into ES, calls interrupt 10h, passes the values of 4
  192. registers back to QBasic.
  193. ===========================================================================
  194. KLS
  195.         Clears the screen, sets the cursor coordinates (RR and CC) to 1.
  196. ===========================================================================
  197. Kolor  foreground, background
  198.         Sets the color for Prnt and PrntW, like Basic's COLOR.
  199. ===========================================================================
  200. Lokate x, y
  201.         Sets the cursor location (used by PrntW, Prnt, PrntS, etc)
  202. by setting the values of RR and CC.  RR and CC are defined as
  203. common shared integers in W30.dec.  It also now moves the visible cursor
  204. to the new location.
  205.         Use basic's LOCATE to change the shape of the cursor.  You may also
  206. have to move the cursor or CLS to make it take effect.  I expect some
  207. problems with keeping the cursor visible and the right shape, expecially when
  208. using the VGA modes.  Example to make a block cursor:
  209.         CLS : Locate 1,1,1,1,12
  210. ===========================================================================
  211. MonoChrome      Changes the video segment to B000h for use with the
  212.        monochrome adapter.
  213. ===========================================================================
  214. OpenW (border, attribute, segment, TR, LC, BR, RC)
  215.         Saves the window like SaveW.  In addition, the area in the
  216.         window is blanked and a border drawn around it.  The values
  217.         for border are:
  218.                0       no border
  219.                1       single line
  220.                2       double line
  221.                3       double line at top and bottom, single line on sides
  222.                4       User defined (by Call DefBorder)
  223.        No border is used if the box has less than 3 lines or columns
  224.  
  225. If the segment passed is 0 the data is not saved and you do not have
  226.        to dimension an array.  This is used to draw a box, set up
  227.        coordinates for FillW and erase the window. Example:
  228.        call OpenW(2,7,0,2,20,10,40)
  229.  
  230.        The sub Machine in WDemo.bas demonstrates using  OpenW to draw
  231.        a black rectangle.
  232. ===========================================================================
  233. Printt a$,attribute, Row,Column
  234.         print a string at row,column within the boundaries of SetViewPage
  235. ===========================================================================
  236. PrintW  a$,attr,Row,col
  237.         print a string at row,column within the boundaries of the
  238.         currently active window (the window most recently defined by
  239.         OpenW or SaveW).
  240.         Row and Col 1,1 is the top left corner of the screen.  However,
  241.         since these are automatically adjusted to fit within the window,
  242.         if you call PrintW with row and col equal to 1, they will be changed
  243.         to the top left corner of the window.
  244.  
  245. ===========================================================================
  246. Prnt    A$
  247. PrntW   A$
  248.         Same as Printt and PrintW, except that the attribute and location
  249. are passed by Kolor & Lokate.  The cursor is moved to the next space
  250. after the string.
  251. ===========================================================================
  252. PrntS   (BYVAL x!)
  253.         Prints a single-precision number.  Use lokate & kolor to set the
  254. location and color.  It is about twice as fast as QBasic, and 7 times
  255. faster if called directly from assembler.  Maximum of 7 digits right of
  256. the decimal point, about 18 left of the decimal point, and 7 significant
  257. digits.
  258.         This was not easy to write, but I thought it important because it
  259. minimizes the need to mix Prnt and PRINT statements and the problems
  260. associated with passing the cursor location back and forth between
  261. QB4Win and QBasic.
  262.  
  263. ===========================================================================
  264. PrntUsingS      (mask$, x)
  265.         Prints a single precison number using a mask, like PRINT USING.
  266. Only the length of the string and position of the decimal point are
  267. important.
  268.         Example:  x=33.4:PrntUsingS "####.###", x
  269.         Output:    33.400
  270. ===========================================================================
  271. ReadScreen (a$, row, column)
  272.          Reads text from the screen into a string variable.  The
  273. first character is at (row,column) and the number read equals the length
  274. of the string.  Usage:
  275.         a$ = SPACE$(n) : call ReadScreen (a$, row, column)
  276. ===========================================================================
  277. ReturnSegments (cs%, ds%)
  278.         Returns the current data & code segments in two variables.  CS%
  279. is the code segment for QB4Win, and its data starts at offset 0.  DS% is
  280. the data for QBasic.
  281. ===========================================================================
  282. SaveW (segment, TR, LC, BR, RC)
  283.         Saves the contents of the screen inside the window defined by
  284.         Toprow,left column,bottom row and right column into a dynamic
  285.         numeric array.  The coordinates of
  286.         the window are pushed onto the stack for CloseLastW.  The display
  287.         on the screen is not altered.  The contents of the window may be
  288.         restored by calling CloseLastW or CloseW.
  289.  
  290.        If 0 is passed as the segment, the contents of the window are
  291.        not saved, although the data for the window is still pushed onto a
  292.        stack.  This is used to set up the coordinates of a window
  293.        for FillW or PrntW.
  294.        Example to define a window but not save it:
  295.         call SaveW(0,1,1,24,80) : PrintW a$, 7, 1, 1
  296.  
  297.         An example to save  the entire screen:
  298.                 Rem $DYNAMIC
  299.                 REDIM a%(2000):' sets aside 4000 bytes of memory
  300.                 call SaveW (VARSEG(a%(1)),1,1,25,80)
  301. ===========================================================================
  302. SetViewPage  (page)
  303.         Defines the active page. Page is a number from 0 to 3. The
  304. default value is 0.  Typical usage is:
  305.         SCREEN , , page,page : SetViewPage page
  306.  
  307.         Not all the pages available with the VGA are supported.  The page
  308. numbers for each mode:
  309.         25 x  80   0, 1, 2, 3
  310.         25 x 132   0, 1
  311.         34 x  80   0, 1
  312.         37 x 100   0, 1
  313.         34 x 132   0
  314.         43 x  80   0, 1
  315.         42 x 100   0
  316.         43 x 132   0
  317.         50 x  80   0, 1
  318.         50 x 132   0
  319.         60 x  80   0
  320.         75 x 100   0
  321.         60 x 132   0
  322.  
  323. ===========================================================================
  324. SetViewW   ( TR, LC, BR, RC)
  325.       Defines the active portion of the screen.  Similar to
  326. Basic's VIEW PRINT [topline TO bottomline] statement except that
  327. columns is also a parameter.  All the routines in QB4Windows
  328. operate within these boundaries except ChangeAttr and SwapAttr.
  329. Use it to lock out the top or bottom line when that line is used
  330. for a menu.  The default values are 1, 1, 75, 132 for all 4 pages.
  331. ===========================================================================
  332. SwapAttr ()
  333.         Swaps the foreground and background attributes for all the
  334.         characters on the screen (25 lines x 80 columns only), stripping
  335.         off any blinking bits.
  336. ===========================================================================
  337. ScrollU ( attribute, lines, tr, lc, br, rc)
  338. ScrollU,ScrollD,ScrollL,ScrollR scroll the window up,down,left or right.
  339. The information scrolled off the screen is lost, the lines or columns
  340. scrolled onto the screen are blanked using the specified attribute.
  341. example
  342.        ScrollD(7,2,1,1,25,80):'scrolls the entire screen down two lines,
  343.                               'top 2 lines are blanked with attribute 7
  344. If the number of lines or columns to scroll is greater than the number
  345. in the window, the entire window is blanked.
  346.  
  347. ===========================================================================
  348.  
  349.  
  350.  
  351.                         III. Notes
  352.  
  353.                                              
  354. ===========================================================================
  355.         If the program halts at the last line of W30.DEC, highlights "RR"
  356. and displays the message box  "wrong data type", unload W30.DEC. It happens
  357. when you load W30.DEC to edit the file, and may have something to do with
  358. setting the main module.
  359. ===========================================================================
  360.         The calls that don't have arguments can't be the first command
  361. on a line because they will be interpreted as labels instead of commands.
  362. These don't work:
  363.         KLS : Prnt "Hello"
  364.         CloseLastW : EXIT SUB
  365. These do:
  366.         Call KLS: Prnt "Hello"
  367.         KLS
  368. ===========================================================================
  369.         All the print routines check the boundaries set by SetViewW, and
  370. also check the current display.  Windows or Lokates outside these boundaries
  371. are resized to fit the screen.
  372. ===========================================================================
  373.         QBasic saves the current state of the VGA before returning to
  374. the editor, and restores it if you halt and then continue the program, so it
  375. is not possible to change the editor to 43 line mode with W30.BAS.  To use
  376. the editor in this mode, change before invoking QB.EXE.
  377.         Since QBasic 4.0 does not support 132 column modes at all, and
  378. the VGA in this mode (mode 17h) emulates 80 column mode, it is not
  379. advisable to halt a program and try to use the editor while in the 132
  380. column mode.  W30.BAS restores the display to 25 x 80 when "q" is
  381. selected from the main menu.
  382. ===========================================================================
  383.         After any print statement, the values of RR and CC are updated
  384. to reflect the new location that the cursor should be at. When mixing
  385. PRINT and Prnt or PrntS statements, pass the cursor locations back and
  386. forth thusly:
  387.         Prnt A$
  388.         LOCATE RR, CC
  389.         PRINT B$
  390.         Lokate CRSLIN,  POS(0)
  391.         Prnt c$
  392. ===========================================================================
  393. CR$
  394.         If a string printed with Printt, PrintW, Prnt or PrntW is appended
  395.         with a chr$(13) a carriage return\linefeed is executed.  The
  396.         line will be erased to the end and the cursor drops to the beginning
  397.         of the next line, scrolling if necessary.  This is equivalent to
  398.         PRINT a$.  Example:
  399.                 CR$ = Chr$(13): Lokate 1,1
  400.                 Prnt "Hello" + cr$
  401.                 'The cursor will be at 2, 1
  402. ===========================================================================
  403. EOL$
  404.         Appending the string with chr$(10) is the same as chr$(13)
  405.         except that scrolling is suppressed.  Use this to print on the
  406.         last line of the screen and erase to the end of the line without
  407.         causing the screen to scroll.  RR will go out of bounds instead.
  408.  
  409.         Example:
  410.           Lokate 25,1 : EOL$ = chr$(10)
  411.           Prnt "Hello" + EOL$
  412.                  'prints "Hello" and 75 blank spaces
  413.                  'Now RR=26 and CC=1
  414.           Prnt "Goodby"
  415.                 'since RR is > 25, now the screen scrolls up and Goodby
  416.                 ' is printed at 25, 1
  417.  
  418. ===========================================================================
  419.         Prnt and Printx are much faster than Basic, and don't have
  420.         some of its quirks.  For example,
  421.                 Locate 24,79:Print "abc"; :' will scroll the top
  422.                         24 lines and print at 24,1
  423.  
  424.                 Locate 25,79:Print "abc"; :' will also scroll the
  425.                         first 24 lines and print at 24,1
  426.  
  427.                a$="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
  428.                locate 1,1:Print a$;a$;
  429.                'the second a$ will print at 2,1
  430.  
  431. ===========================================================================
  432. Arrays
  433.       =================================================================
  434.      | THE ARRAY MUST BE DYNAMIC.  Use the $DYNAMIC metacommand at the |
  435.      | beginning of the program or sub in which the dim or redim       |
  436.      | statement occurs.  You may also force the  array to be dynamic  |
  437.      | by using variables for the dimensions.  This is most important  |
  438.      | when creating .exe files because they default to static arrays. |
  439.      | The editor\compiler defaults to dynamic.                        |
  440.      | Example: $dynamic                                               |
  441.      |          n=200:redim array%(n)                                  |
  442.      |          Call OpenW(2,7, varseg(array(1)), r,c,rr,cc)           |
  443.      | Putting 'REM $DYNAMIC' at the beginning of a program does NOT   |
  444.      | carry over to subs so put it in each SUB or FUNCTION.  Using a  |
  445.      | variable for the array dimensions [ ex. dim a(x) instead of     |
  446.      | dim a(400) ] will also force the array to be dynamically        |
  447.      | allocated.                                                      |
  448.       =================================================================
  449.  
  450. ===========================================================================
  451.        Attributes
  452.  
  453.          Color:                   Attributes:
  454.  
  455.        Color 2,0               Attr% = 2       Normal
  456.        Color 15,0              Attr% = &hF     Bright
  457.        Color 0,2               Attr% = &h20    Reverse
  458.              | |__background             ||_____Forground Color
  459.              |_______foreground          |_________Background Color
  460. ===========================================================================
  461. W30.DEC
  462.         This is an include file which contains all the DECLARE statement
  463. needed. Most of these include BYVAL declarations, allowing numbers to be
  464. expressed in just about any form and automatically converted to integers.
  465. It also contains two executable statements:
  466.                 COMMON SHARED RR AS INTEGER, CC AS INTEGER
  467.                 InitW  RR, CC
  468.  
  469.         Since Lokate and Prnt need the addresses of RR and CC,
  470. these are declared as global variables, then passed via InitW.
  471.  
  472.         The statement
  473.                    REM $INCLUDE:'W30.DEC'
  474. should be included in every module of a program.
  475. COMMON SHARED statements must precede the $INCLUDE statement, and
  476. other executable statements may not precede it.
  477.  
  478. ===========================================================================
  479.  
  480.        Files included:
  481.    MakeLib.bat     creates the .QLB and .LIB files from object files
  482.                    This is already done, included in case you want to link
  483.                    other object files to W30.obj
  484.  
  485.    W30Demo.bat     runs the demo program
  486.  
  487.    QB4.bat         invokes QuickBasic with the  window library
  488.  
  489.    W30.bas         demo.
  490.  
  491.    W30.DEC         An include file containing declare
  492.                    statements, and two program statements to initialize
  493.                    QB4windows.
  494.  
  495.    W30.doc           documentation
  496.  
  497.    W30.lib & W30.QLB library files containing the windows program.
  498.  
  499.    Q30.obj          object file.
  500.  
  501.    W30.VPT         a color definition file used by W30.BAS
  502.  
  503. ===========================================================================
  504.        LOCK UPS
  505.        If your computer locks up or loses data, check the following:
  506.        Saved to an array that was too small.
  507.        Passed the wrong segment.
  508.        Used a static array.
  509.        Did not include W30.DEC
  510.        Did not pass a value BYVAL and as an integer.  The DECLARE
  511.                statements will convert any kind of number to an integer,
  512.                pass it as a value, and check for the correct number of
  513.                arguments.  For example,
  514.                        Call OpenW(b,&h70,varseg(x(1)),a%,b!,c, 79.64)
  515.                works even though the numbers are not all integers.
  516.  
  517.        Remember, it is up to YOU to protect valuable data and programs.
  518.  
  519. ===========================================================================
  520. Segments
  521.        To provide memory to store the data under a window, dimension
  522.        a numeric array.  The segment of that array is passed to OpenW
  523.        and SaveW and the data under the window is copied to the memory
  524.        reserved for the array.
  525.        Each character on the screen takes 2 bytes (1 for text, 1 for
  526.        attribute).
  527.        The maximum required for an 80 x 25 display is 4000 bytes.
  528.        Redim a!(1000) or a%(2000) will provide 4000 bytes.  To be exact,
  529.                lines = BR - TR + 1
  530.                Cols  = RC - LC + 1
  531.                redim a%(  lines * cols  )
  532.  
  533. ===========================================================================
  534.        TR, LC,BR,RC
  535.        RR,CC
  536.  
  537.        TopRow and LeftColumn define the top left corner of a window,
  538.        BottomRow and RightColumn define the bottom right corner.
  539.        When a call is made using window coordinates, W30 first
  540.        checks these arguments.  If TR or BR are less than the top of
  541.        the screen as defined by SetViewW, they are increased.  If
  542.        larger than allowed by SetViewW or by the size of the current
  543.        display mode, they are decreased.  Same for Columns.  Then if BR is less
  544.        than TR, they are swapped.
  545.  
  546.        If the row for Printt or Lokate is above the top line of the window it is
  547.        moved to the top line.  If column is less than the left column it
  548.        is moved over to the first column
  549.        If the column is greater than the right column, RR and CC are moved
  550.        to the start of the next line.
  551.        If RR is greater than the last line, the window is scrolled up a line
  552.        and RR and CC are set to the beginning of the last line.
  553.         Examples:
  554.                 Lokate 0,0:PrntW a$   ;prints at the top left of the window
  555.                 Lokate 26,1:Prnt a$   ;Scroll, print at 25,1
  556.  
  557. ==============================================================================
  558.         Basic stores it's cursor coordinates for the row & column at
  559. DGroup:17C2 and Dgroup:17C3 (1 byte each).  Poking RR and CC here makes it
  560. print at RR,CC but doesn't affect the location of INPUT statements. If you
  561. know it is all right to change these values or know more about this, please
  562. write.
  563. ==============================================================================
  564.