home *** CD-ROM | disk | FTP | other *** search
- This is another (ho-hum) Quickbasic library, dealing almost
- exclusively with routines that print text. Most such libraries are a
- series of short, pretty much independent calls. This one is more
- integrated in that calls such as KLS, Prnt, Kolor and Lokate
- share data, as do OpenW, FillW, and CloseLastW and others. It gives you
- the ability to set the display to any of the VGA text modes, print strings
- and numbers on 132 column displays, read and set the VGA color registers,
- in addition to the usual windows routines.
-
- Feel free to write if you think you have found a bug or
- the program doesn't work as expected. You might first check for a newer
- version, and may also try leaving a message on the Odie link. New versions
- of QB4Win can usually be found on these BBS's:
- Exec-PC (414) - 964 - 5160
- The Utilities Exchange (614) - 442 - 6695
- Jesse's Board (513) - 385 - 8512
- Greater Cincinnatti PC users (513) - 221 - 7284
- Public Domain SIG (619) - 749 - 2741
- Odie link (614) - 335 - 3972.
- ================================================================================
-
- Documentation for QBasic Windows Version 3.0 April 1989
-
- The calls are listed in this file in alphabetical order, followed by
- the notes.
-
- The documentation for W30.bas and most of the VGA routines is
- in W30.BAS in the sub W30DOC.
-
- * denotes new or changed in this version
-
- I. Window Routines
-
- OpenW FillW *SetViewP
- SaveW InitW SetViewW
- CloseW DebugW
- CloseLastW DefBorder *Dump2
-
-
- II. Print routines
-
- Printt PrintW *Lokate
- Prnt PrntW Kolor
- *PrntS *PrntUsingS *KLS
-
-
- III. Misc
- ScrollU ReadScreen ChangeAttr
- ScrollD Int3 SwapAttr
- ScrollL *Int10 CGA
- ScrollR *Adapter Monochrome
- *ReturnSegments
-
- III. Notes
-
- Arrays Files Segments
- Attributes Lockups TR,LC,BR,RC
- W30.DEC
-
- ===========================================================================
- If you will, let me know how successful this program has been.
-
- James A. Paisley
- 10690 Allen Rd NW
- Washington C.H.,Oh 43160
-
- Name _________________________________________
-
- Address __________________________________________
-
- __________________________________________
-
- I have version________3.0_____
-
-
- Enclose $5 if you want the source code, about 3500 lines in assembler.
-
- ===========================================================================
- Adapter (a%)
- Pass an integer variable to this call to find what kind of video
- adapter is active. I have not tested it with anything except a VGA. A
- VGA will return a value of 3 even if it is emulating a CGA or EGA.
- Return codes:
- 0 - monochrome
- 1 - CGA
- 2 - EGA
- 3 - VGA
- ===========================================================================
- CGA ()
- Changes the video segment to B800h for use with the
- CGA, EGA or VGA. This is the default value.
- ===========================================================================
- ChangeAttr (attr)
- Changes all the attributes on the screen to a given value. Assumes
- the display is 25 x 80.
- ===========================================================================
- CloseLastW ()
- Closes the most recently opened window (created with OpenW or SaveW).
- The coordinates and segment of the last ten windows are saved on a
- revolving stack so it may be called up to ten times. CloseW will bump
- the last one off the stack. OpenW and SaveW add one to the stack (even
- if the segment is 0). Call DebugW to view the stack.
- Example:
- redim b(1000):
- CALL SaveW(VARSEG(b(1)), 1, 1, 24, 80)
- call OpenW(2,&h30,0,1,40,10,60)
- call CloseLastW
- call CloseLastW
- ===========================================================================
- CloseW (segment,TR,LC,BR,RC)
- Closes a window opened by either SaveW or OpenW. The window may be
- moved or copied to a new location on the screen by changing the
- coordinates.
- ===========================================================================
- DebugW ()
- Prints information about the current values for QB4Windows
- parameters.
- ===========================================================================
- DefBorder(x$)
- Allows the user to define a new border. X$ is a string of nine characters
- for the top left corner
- top row
- top right corner
- left side
- middle
- bottom left corner
- bottom line
- bottom right corner
- DefBorder may also be used to fill an area of the screen with a
- character. For example, to fill the entire screen with periods:
- Call DefBorder (".........")
- call OpenW(4,attribute,0,1,1,25,80)
-
- ===========================================================================
- Dump2 (r, c, attr, border, NLines, Ncol, seg, offset, format, refreshRate)
- Does a debug-style memory dump. W30.BAS demonstrates this routine
- by using a sort of multi-tasking to do an X-RAY type dump of the keyboard
- buffer.
- R & C Start printing at this row and column
- attr defines the color
- border same as borders used by OpenW
- NLines # of lines to dump
- Ncol not used with this format
- Seg Segment to display
- Offset Offset to display
- format not used
- rate not used
- The Offset is an integer variable ( not BYVAL), and is changed after the
- call so you may scroll thru memory without redefining the offset.
- The call Refresh simply repeats the last call to dump2, but faster because
- no data is passed.
- You should be able to display the memory dump on a second monitor
- by switching between the cga & vga video segments:
- Call Mono: Call Refresh: Call CGA
- ===========================================================================
- FillW ( n , varptr(a$(L) )
- Fills a window with strings from an array.
- The coordinates used are those
- of the window most recently opened with OpenW or SaveW. The first n
- characters of each string are skipped, so increasing n has the effect of
- scrolling to the left. Increasing L has the effect of scrolling up.
- Example: call OpenW(2,7,0,2,20,10,40)
- redim a$(500)
- [ assign strings to a$() ]
- n=0:L=1
- call FillW(n,varptr(a$(L))
-
- The sub FILL in WDemo.bas demonstrates using FillW to view a file and
- the main menu uses it to fill a menu box.
- This will not work with an array of fixed length strings.
- ===========================================================================
- GScrollL8 (TR, LC, BR, RC)
- Scrolls left 8 pixels in graphics mode (screen 1 and screen 2).
- tr and br are numbers from 0 to 199
- lc and rc are from 0 to 639 and are rounded down to the nearest multiple of 8.
- there is no error checking, wierd values could make it hang
- not thoroughly tested
- ===========================================================================
- InitW (RR%, CC%)
- Resets all the parameters for windows to their default values.
- This should be called at the beginning of a program. If the
- program is halted and run again, the defaults may be incorrect.
- This call passes the integer variables RR and CC so that Lokate,
- Prnt and PrntW can find them.
- The call to InitW is included in W30.DEC.
- ===========================================================================
- int3 ()
- calls interrupt 3
- ===========================================================================
- Int10 (ax%, bx%, cx%, dx%)
- Copies DS into ES, calls interrupt 10h, passes the values of 4
- registers back to QBasic.
- ===========================================================================
- KLS
- Clears the screen, sets the cursor coordinates (RR and CC) to 1.
- ===========================================================================
- Kolor foreground, background
- Sets the color for Prnt and PrntW, like Basic's COLOR.
- ===========================================================================
- Lokate x, y
- Sets the cursor location (used by PrntW, Prnt, PrntS, etc)
- by setting the values of RR and CC. RR and CC are defined as
- common shared integers in W30.dec. It also now moves the visible cursor
- to the new location.
- Use basic's LOCATE to change the shape of the cursor. You may also
- have to move the cursor or CLS to make it take effect. I expect some
- problems with keeping the cursor visible and the right shape, expecially when
- using the VGA modes. Example to make a block cursor:
- CLS : Locate 1,1,1,1,12
- ===========================================================================
- MonoChrome Changes the video segment to B000h for use with the
- monochrome adapter.
- ===========================================================================
- OpenW (border, attribute, segment, TR, LC, BR, RC)
- Saves the window like SaveW. In addition, the area in the
- window is blanked and a border drawn around it. The values
- for border are:
- 0 no border
- 1 single line
- 2 double line
- 3 double line at top and bottom, single line on sides
- 4 User defined (by Call DefBorder)
- No border is used if the box has less than 3 lines or columns
-
- If the segment passed is 0 the data is not saved and you do not have
- to dimension an array. This is used to draw a box, set up
- coordinates for FillW and erase the window. Example:
- call OpenW(2,7,0,2,20,10,40)
-
- The sub Machine in WDemo.bas demonstrates using OpenW to draw
- a black rectangle.
- ===========================================================================
- Printt a$,attribute, Row,Column
- print a string at row,column within the boundaries of SetViewPage
- ===========================================================================
- PrintW a$,attr,Row,col
- print a string at row,column within the boundaries of the
- currently active window (the window most recently defined by
- OpenW or SaveW).
- Row and Col 1,1 is the top left corner of the screen. However,
- since these are automatically adjusted to fit within the window,
- if you call PrintW with row and col equal to 1, they will be changed
- to the top left corner of the window.
-
- ===========================================================================
- Prnt A$
- PrntW A$
- Same as Printt and PrintW, except that the attribute and location
- are passed by Kolor & Lokate. The cursor is moved to the next space
- after the string.
- ===========================================================================
- PrntS (BYVAL x!)
- Prints a single-precision number. Use lokate & kolor to set the
- location and color. It is about twice as fast as QBasic, and 7 times
- faster if called directly from assembler. Maximum of 7 digits right of
- the decimal point, about 18 left of the decimal point, and 7 significant
- digits.
- This was not easy to write, but I thought it important because it
- minimizes the need to mix Prnt and PRINT statements and the problems
- associated with passing the cursor location back and forth between
- QB4Win and QBasic.
-
- ===========================================================================
- PrntUsingS (mask$, x)
- Prints a single precison number using a mask, like PRINT USING.
- Only the length of the string and position of the decimal point are
- important.
- Example: x=33.4:PrntUsingS "####.###", x
- Output: 33.400
- ===========================================================================
- ReadScreen (a$, row, column)
- Reads text from the screen into a string variable. The
- first character is at (row,column) and the number read equals the length
- of the string. Usage:
- a$ = SPACE$(n) : call ReadScreen (a$, row, column)
- ===========================================================================
- ReturnSegments (cs%, ds%)
- Returns the current data & code segments in two variables. CS%
- is the code segment for QB4Win, and its data starts at offset 0. DS% is
- the data for QBasic.
- ===========================================================================
- SaveW (segment, TR, LC, BR, RC)
- Saves the contents of the screen inside the window defined by
- Toprow,left column,bottom row and right column into a dynamic
- numeric array. The coordinates of
- the window are pushed onto the stack for CloseLastW. The display
- on the screen is not altered. The contents of the window may be
- restored by calling CloseLastW or CloseW.
-
- If 0 is passed as the segment, the contents of the window are
- not saved, although the data for the window is still pushed onto a
- stack. This is used to set up the coordinates of a window
- for FillW or PrntW.
- Example to define a window but not save it:
- call SaveW(0,1,1,24,80) : PrintW a$, 7, 1, 1
-
- An example to save the entire screen:
- Rem $DYNAMIC
- REDIM a%(2000):' sets aside 4000 bytes of memory
- call SaveW (VARSEG(a%(1)),1,1,25,80)
- ===========================================================================
- SetViewPage (page)
- Defines the active page. Page is a number from 0 to 3. The
- default value is 0. Typical usage is:
- SCREEN , , page,page : SetViewPage page
-
- Not all the pages available with the VGA are supported. The page
- numbers for each mode:
- 25 x 80 0, 1, 2, 3
- 25 x 132 0, 1
- 34 x 80 0, 1
- 37 x 100 0, 1
- 34 x 132 0
- 43 x 80 0, 1
- 42 x 100 0
- 43 x 132 0
- 50 x 80 0, 1
- 50 x 132 0
- 60 x 80 0
- 75 x 100 0
- 60 x 132 0
-
- ===========================================================================
- SetViewW ( TR, LC, BR, RC)
- Defines the active portion of the screen. Similar to
- Basic's VIEW PRINT [topline TO bottomline] statement except that
- columns is also a parameter. All the routines in QB4Windows
- operate within these boundaries except ChangeAttr and SwapAttr.
- Use it to lock out the top or bottom line when that line is used
- for a menu. The default values are 1, 1, 75, 132 for all 4 pages.
- ===========================================================================
- SwapAttr ()
- Swaps the foreground and background attributes for all the
- characters on the screen (25 lines x 80 columns only), stripping
- off any blinking bits.
- ===========================================================================
- ScrollU ( attribute, lines, tr, lc, br, rc)
- ScrollU,ScrollD,ScrollL,ScrollR scroll the window up,down,left or right.
- The information scrolled off the screen is lost, the lines or columns
- scrolled onto the screen are blanked using the specified attribute.
- example
- ScrollD(7,2,1,1,25,80):'scrolls the entire screen down two lines,
- 'top 2 lines are blanked with attribute 7
- If the number of lines or columns to scroll is greater than the number
- in the window, the entire window is blanked.
-
- ===========================================================================
-
-
-
- III. Notes
-
-
- ===========================================================================
- If the program halts at the last line of W30.DEC, highlights "RR"
- and displays the message box "wrong data type", unload W30.DEC. It happens
- when you load W30.DEC to edit the file, and may have something to do with
- setting the main module.
- ===========================================================================
- The calls that don't have arguments can't be the first command
- on a line because they will be interpreted as labels instead of commands.
- These don't work:
- KLS : Prnt "Hello"
- CloseLastW : EXIT SUB
- These do:
- Call KLS: Prnt "Hello"
- KLS
- ===========================================================================
- All the print routines check the boundaries set by SetViewW, and
- also check the current display. Windows or Lokates outside these boundaries
- are resized to fit the screen.
- ===========================================================================
- QBasic saves the current state of the VGA before returning to
- the editor, and restores it if you halt and then continue the program, so it
- is not possible to change the editor to 43 line mode with W30.BAS. To use
- the editor in this mode, change before invoking QB.EXE.
- Since QBasic 4.0 does not support 132 column modes at all, and
- the VGA in this mode (mode 17h) emulates 80 column mode, it is not
- advisable to halt a program and try to use the editor while in the 132
- column mode. W30.BAS restores the display to 25 x 80 when "q" is
- selected from the main menu.
- ===========================================================================
- After any print statement, the values of RR and CC are updated
- to reflect the new location that the cursor should be at. When mixing
- PRINT and Prnt or PrntS statements, pass the cursor locations back and
- forth thusly:
- Prnt A$
- LOCATE RR, CC
- PRINT B$
- Lokate CRSLIN, POS(0)
- Prnt c$
- ===========================================================================
- CR$
- If a string printed with Printt, PrintW, Prnt or PrntW is appended
- with a chr$(13) a carriage return\linefeed is executed. The
- line will be erased to the end and the cursor drops to the beginning
- of the next line, scrolling if necessary. This is equivalent to
- PRINT a$. Example:
- CR$ = Chr$(13): Lokate 1,1
- Prnt "Hello" + cr$
- 'The cursor will be at 2, 1
- ===========================================================================
- EOL$
- Appending the string with chr$(10) is the same as chr$(13)
- except that scrolling is suppressed. Use this to print on the
- last line of the screen and erase to the end of the line without
- causing the screen to scroll. RR will go out of bounds instead.
-
- Example:
- Lokate 25,1 : EOL$ = chr$(10)
- Prnt "Hello" + EOL$
- 'prints "Hello" and 75 blank spaces
- 'Now RR=26 and CC=1
- Prnt "Goodby"
- 'since RR is > 25, now the screen scrolls up and Goodby
- ' is printed at 25, 1
-
- ===========================================================================
- Prnt and Printx are much faster than Basic, and don't have
- some of its quirks. For example,
- Locate 24,79:Print "abc"; :' will scroll the top
- 24 lines and print at 24,1
-
- Locate 25,79:Print "abc"; :' will also scroll the
- first 24 lines and print at 24,1
-
- a$="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
- locate 1,1:Print a$;a$;
- 'the second a$ will print at 2,1
-
- ===========================================================================
- Arrays
- =================================================================
- | THE ARRAY MUST BE DYNAMIC. Use the $DYNAMIC metacommand at the |
- | beginning of the program or sub in which the dim or redim |
- | statement occurs. You may also force the array to be dynamic |
- | by using variables for the dimensions. This is most important |
- | when creating .exe files because they default to static arrays. |
- | The editor\compiler defaults to dynamic. |
- | Example: $dynamic |
- | n=200:redim array%(n) |
- | Call OpenW(2,7, varseg(array(1)), r,c,rr,cc) |
- | Putting 'REM $DYNAMIC' at the beginning of a program does NOT |
- | carry over to subs so put it in each SUB or FUNCTION. Using a |
- | variable for the array dimensions [ ex. dim a(x) instead of |
- | dim a(400) ] will also force the array to be dynamically |
- | allocated. |
- =================================================================
-
- ===========================================================================
- Attributes
-
- Color: Attributes:
-
- Color 2,0 Attr% = 2 Normal
- Color 15,0 Attr% = &hF Bright
- Color 0,2 Attr% = &h20 Reverse
- | |__background ||_____Forground Color
- |_______foreground |_________Background Color
- ===========================================================================
- W30.DEC
- This is an include file which contains all the DECLARE statement
- needed. Most of these include BYVAL declarations, allowing numbers to be
- expressed in just about any form and automatically converted to integers.
- It also contains two executable statements:
- COMMON SHARED RR AS INTEGER, CC AS INTEGER
- InitW RR, CC
-
- Since Lokate and Prnt need the addresses of RR and CC,
- these are declared as global variables, then passed via InitW.
-
- The statement
- REM $INCLUDE:'W30.DEC'
- should be included in every module of a program.
- COMMON SHARED statements must precede the $INCLUDE statement, and
- other executable statements may not precede it.
-
- ===========================================================================
-
- Files included:
- MakeLib.bat creates the .QLB and .LIB files from object files
- This is already done, included in case you want to link
- other object files to W30.obj
-
- W30Demo.bat runs the demo program
-
- QB4.bat invokes QuickBasic with the window library
-
- W30.bas demo.
-
- W30.DEC An include file containing declare
- statements, and two program statements to initialize
- QB4windows.
-
- W30.doc documentation
-
- W30.lib & W30.QLB library files containing the windows program.
-
- Q30.obj object file.
-
- W30.VPT a color definition file used by W30.BAS
-
- ===========================================================================
- LOCK UPS
- If your computer locks up or loses data, check the following:
- Saved to an array that was too small.
- Passed the wrong segment.
- Used a static array.
- Did not include W30.DEC
- Did not pass a value BYVAL and as an integer. The DECLARE
- statements will convert any kind of number to an integer,
- pass it as a value, and check for the correct number of
- arguments. For example,
- Call OpenW(b,&h70,varseg(x(1)),a%,b!,c, 79.64)
- works even though the numbers are not all integers.
-
- Remember, it is up to YOU to protect valuable data and programs.
-
- ===========================================================================
- Segments
- To provide memory to store the data under a window, dimension
- a numeric array. The segment of that array is passed to OpenW
- and SaveW and the data under the window is copied to the memory
- reserved for the array.
- Each character on the screen takes 2 bytes (1 for text, 1 for
- attribute).
- The maximum required for an 80 x 25 display is 4000 bytes.
- Redim a!(1000) or a%(2000) will provide 4000 bytes. To be exact,
- lines = BR - TR + 1
- Cols = RC - LC + 1
- redim a%( lines * cols )
-
- ===========================================================================
- TR, LC,BR,RC
- RR,CC
-
- TopRow and LeftColumn define the top left corner of a window,
- BottomRow and RightColumn define the bottom right corner.
- When a call is made using window coordinates, W30 first
- checks these arguments. If TR or BR are less than the top of
- the screen as defined by SetViewW, they are increased. If
- larger than allowed by SetViewW or by the size of the current
- display mode, they are decreased. Same for Columns. Then if BR is less
- than TR, they are swapped.
-
- If the row for Printt or Lokate is above the top line of the window it is
- moved to the top line. If column is less than the left column it
- is moved over to the first column
- If the column is greater than the right column, RR and CC are moved
- to the start of the next line.
- If RR is greater than the last line, the window is scrolled up a line
- and RR and CC are set to the beginning of the last line.
- Examples:
- Lokate 0,0:PrntW a$ ;prints at the top left of the window
- Lokate 26,1:Prnt a$ ;Scroll, print at 25,1
-
- ==============================================================================
- Basic stores it's cursor coordinates for the row & column at
- DGroup:17C2 and Dgroup:17C3 (1 byte each). Poking RR and CC here makes it
- print at RR,CC but doesn't affect the location of INPUT statements. If you
- know it is all right to change these values or know more about this, please
- write.
- ==============================================================================
-