!SHORT:Attr Combine frgrnd and bkgrnd colors as single attribute byte Attr FastTTT Purpose To combine foreground and background colors as a single attribute byte. Result type byte; Declaration Attr(F,B:byte):byte; F is the foreground color (0..15) B is the background color (0..15) Uses FastTTT. Remarks The video memory for an 80 by 25 character screen is composed of 2000 bytes of data. There is an attribute byte and a character byte for each of the 1000 character positions on the screen. This simple function will combine a foreground color (F) with a background color (B) to form a single attribute byte. The valid color ranges are 0 to 15. (Refer to Appendix B for a color table.) If a background color is set greater than 7 then "flashing" characters will result. Example USES FASTTTT; VAR MSG_COL : BYTE; BEGIN MSG_COL := ATTR(15,4); END. The color attribute MSG_COL would be set to white on a red background. !SEEALSO:FastWrite PlainWrite !SHORT:Box Draw a rectangle or box on screen Box FastTTT Purpose To draw a rectangle or box on the screen. Declaration Box(X1,Y1,X2,Y2,F,B,Boxtype: byte); X1 is the top left X coordinate (1..79) Y1 is the top left Y coordinate (1..24) X2 is lower right X coordinate (2..80) Y2 is lower right Y coordinate (2..25) F is the foreground color (0..15) B is the background color (0..15) Boxtype is the box line type (see remarks) Uses FastTTT. Remarks The area inside the box is not cleared. The normal values for the Boxtype are: 1 Single line 2 Double line 3 Single top/bottom, double sides 4 Double top/bottom, single sides If a BoxType of 0 is passed the the procedure will use a space (' ') as the box character. If any other number (i.e. 5..256) is used, the box is drawn using the ascii character represented by the number. Refer to the Turbo Pascal Owner's Handbook page 568 to see the ascii table. Example USES CRT, FASTTTT; BEGIN CLRSCR; BOX(1,1,80,12,WHITE,RED,1); BOX(1,13,80,25,BLUE,LIGHTGRAY,2); END. The screen would be cleared, a single lined box would be drawn on the top half of the screen, and a double lined box in the lower half. Note that the CRT unit was also USED - this allowed the use of ClrScr, and the colors could be referred to by name rather than their numeric code. !SEEALSO:FBox GrowFBox !SHORT:Clearline Clear all text on a specific line of screen ClearLine FastTTT Purpose To clear all text on a specific line of the screen. Declaration ClearLine(Y,F,B:integer); Y is the line number on the screen to be cleared (1..25) F is the foreground color of the blank line (0..15) B is the background color of the blank line (0..15) Uses FastTTT. Remarks The actual display color of the line will be set to B. The only reason for setting the foreground color is to change the attribute byte, for subsequent writes. Example USES FASTTTT; BEGIN CLEARLINE(25,15,0); END. The 25th line of the screen is cleared with a black background. !SEEALSO:ClearText !SHORT:ClearText Clear all text on a rectangular section of screen ClearText FastTTT Purpose To clear all text on a rectangular section of the screen. Declaration ClearText(X1,Y1,X2,Y2,F,B:integer); X1 is the top left X coordinate (1..79) Y1 is the top left Y coordinate (1..24) X2 is lower right X coordinate (2..80) Y2 is lower right Y coordinate (2..25) F is the foreground color of the blank line (0..15) B is the background color of the blank line (0..15) Uses FastTTT. Remarks The actual display color of the area will be set to B. The only reason for setting the foreground color is to change the attribute byte, for subsequent writes. Example USES FASTTTT; BEGIN CLEARTEXT(1,1,40,25,15,0); END. The lefthand side of the screen is cleared with a black background. !SEEALSO:ClearLine PlainWrite !SHORT:CurrentDisplay Used internally to determine the current type of videocard CurrentDisplay FastTTT Purpose Used internally to determine the current type of videocard. Result DisplayType; Declaration CurrentDisplay: DisplayType; The DisplayType is Monochrome, CGA, EGA, MCGA, or VGA Uses FastTTT. Remarks This function is used internally. !SEEALSO:ReinitFastwrite !SHORT:Fastwrite Core procedure of the unit for fast screen writes Fastwrite FastTTT Purpose The core procedure of the unit for fast screen writes. Declaration Fastwrit(Col, Row, Attr:byte; St: string);external Col is the X coord of first char. in string (1..80) Row is the Y coord of string (1..25) Attr is the color attribute St is the string or text to be displayed Uses FastTTT. Remarks This procedure is external and the source code is actually in assembly language. (See the file FastTTT.asm on the distribution disk, if you're interested.) I recommend you use the WriteAT procedure in preference to Fastwrit, because it can pass foreground and background colors rather then the combined color attribute. If the text is too long to fit on the screen, it will be wrapped onto the next line. Example USES FASTTTT BEGIN FASTWRITE(1,1,14,'TOP LEFT OF SCREEN'); FASTWRITE(59,25,ATTR(14,4),'BOTTOM RIGHT OF SCREEN;); END; !SEEALSO:Attr WriteAT PlainWrite WriteVert !SHORT:Fbox Draw a box and clear screen inside the box FBox FastTTT Purpose To draw a box and clear the screen inside the box. Declaration FBox(X1,Y1,X2,Y2,F,B,Boxtype:integer); X1 is the top left X coordinate (1..79) Y1 is the top left Y coordinate (1..24) X2 is lower right X coordinate (2..80) Y2 is lower right Y coordinate (2..25) F is the foreground color (0..15) B is the background color (0..15) Boxtype is the box line type (see remarks) Uses FastTTT. Remarks The normal values for the Boxtype are: 1 Single line 2 Double line 3 Single top/bottom, double sides 4 Double top/bottom, single sides If a BoxType of 0 is passed, the procedure will use a space (' ') as the box character. If any other number (i.e. 5..256) is used, the box is drawn using the ascii character represented by the number. Refer to page 568 of the Turbo Pascal Owner's Handbook to see the ascii table. Example USES CRT, FASTTTT; BEGIN FBOX(1,1,80,12,WHITE,RED,1); FBOX(1,13,80,25,BLUE,LIGHTGRAY,2); END. A single lined box would be drawn on the top half of the screen and the area inside the box would be cleared to a red background. A double lined box would be drawn in the lower half, and the area inside the box would be cleared to lightgray. Note that the CRT unit was also USED, so the colors could be refered to by name rather than their numeric code. !SEEALSO:Box GrowFBox !SHORT:GrowFBox Draw box and clear screen inside box; box grows on screen GrowFBox FastTTT Purpose To draw a box and clear the screen inside the box. This procedure is the functional equivalent to FBox, but the box grows (or explodes!) on the screen for a fancy visual effect. Declaration GrowFBox(X1,Y1,X2,Y2,F,B,Boxtype:integer); X1 is the top left X coordinate (1..79) Y1 is the top left Y coordinate (1..24) X2 is lower right X coordinate (2..80) Y2 is lower right Y coordinate (2..25) F is the foreground color (0..15) B is the background color (0..15) Boxtype is the box line type (see remarks) Uses FastTTT. Remarks The normal values for the Boxtype are: 1 Single line 2 Double line 3 Single top/bottom, double sides 4 Double top/bottom, single sides If a BoxType of 0 is passed the the procedure will use a space (' ') as the box character. If any other number (i.e. 5..256) is used the box is drawn using the ascii character represented by the number. Refer to page 568 of the Turbo Pascal Owner's Handbook to see the ascii table. If the box grows too quickly or too slowly, alter the global variable Speed. The default value is 200; increase the value to slow the speed down (ugh!) or decrease it to speed the box up. Example USES CRT, FASTTTT; BEGIN SPEED := 400; GROWFBOX(1,1,80,12,WHITE,RED,1); GROWFBOX(1,13,80,25,BLUE,LIGHTGRAY,2); END. !SEEALSO:Box FBox !SHORT:HorizLine Draw a horixontal lin on screen HorizLine FastTTT Purpose To draw a horizontal line on the screen. Declaration HorizLine(X1,X2,Y,F,B,LineType: integer); X1 is the left X coordinate (1..79) X2 is the right X coordinate (2..80) Y is the Y coordinate (1..25) F is the foreground color (0..15) B is the background color (0..15) Linetype is the line type (see remarks) Uses FastTTT. Remarks The normal values for the Linetype are: 1 Single line 2 Double line X2 may be larger than X1. Example USES CRT,FASTTTT; BEGIN HORIZTLINE(10,17,13,LIGHTCYAN,BLUE,1); END. Draws a single horizontal line across the center of the screen. !SEEALSO:VertLine !SHORT:PlainWrite Write text to screen very quickly in default color attribute PlainWrite FastTTT Purpose To write text to the screen very quickly in the default color attribute. Declaration PlainWrite(Col, Row: byte; St: string); external; Col is the X coord of first char. in string (1..80) Row is the Y coord of string (1..25) St is the string or text to be displayed Uses FastTTT. Remarks This procedure is external and the source code is actually in assembly language (see the file FastTTT.asm on the distribution disk, if you're interested). This procedure is very similar to Fastwrite but it uses the current color attribute for each character. It is even faster than Fastwrite! Example USES CRT, FASTTTT BEGIN CLEARTEXT(1,1,80,25,WHITE,BLACK); PLAINWRITE(1,1,'TOP LEFT OF SCREEN'); PLAINWRITE(59,25,'BOTTOM RIGHT OF SCREEN;); END; The screen is cleared to a black background with a white foreground, and the two phrases are written to the screen in white letters. !SEEALSO:WriteAT FastWrite WriteVert !SHORT:ReInitFastWrite Initialize variables referenced internally by FastWrite ReInitFastWrite FastTTT Purpose To initialize variables referenced internally by Fastwrite. Declaration ReinitFastWrite;external; Uses FastTTT. Remarks This procedure is automatically called at the commencement of any program that uses the FastTTT unit. (Refer to page 64 of the Turbo Pascal Owner's Handbook for a further explanation of initialized procedures.) It would not normally be necessary to call this procedure. This procedure is external and the source code is actually in assembly language. (See the file FastTTT.asm on the distribution disk, if you're interested.) !SHORT:Replicate Consrtuct a string of repeated characters Replicate FastTTT Purpose To construct a string of repeated characters Declaration (N:byte; C:Char): string; Uses FastTTT. Result type String Remarks This function uses memory moves and is much faster than a "for" loop. Example USES FASTTTT; VAR TXT:STRING; BEGIN TXT := REPLICATE(80,'+'); FASTWRITE(1,1,14,TXT); END. The variable Txt is set to an 80 character string composed of +'s i.e. '++++++++++....+++++++++'. The string is then written to the first line of the screen in yellow. Note that these two procedures could be combined to form a single statement: FastWrite(1,1,14,Replicate(80,'+')); !SHORT:VertLine Draw a vertical line on screen VertLine FastTTT Purpose To draw a vertical line on the screen. Declaration VertLine(X,Y1,Y2,F,B,LineType: integer); X is the X coordinate (1..80) Y1 is the upper Y coordinate (1..24) Y2 is the lower Y coordinate (2..25) F is the foreground color (0..15) B is the background color (0..15) Linetype is the line type (see remarks) Uses FastTTT. Remarks The normal values for the Linetype are: 1 Single line 2 Double line Y2 may be larger than Y1. Example USES CRT,FASTTTT; BEGIN VERTLINE(40,1,25,LIGHTCYAN,BLUE,2); END. Draws a double vertical line down the center of the screen. !SEEALSO:HorizLine !SHORT:WriteAT Writes directly to screen quickly in specified colors WriteAT FastTTT Purpose To writes directly to the screen el quicko in specified colors. Declaration WriteAT(X,Y,F,B: integer; St: string); X is the X coord of first character in the string (1..80) Y is Y coord of string F is the foreground color (0..15) B is the background color (0..15) St is the text string Uses FastTTT. Remarks This is the most frequently used procedure in the Toolkit. It is preferrable to Fastwrite (for most of us), because you can specify the foreground and background colors separately. This procedure cannot be used to write integers or reals - first convert the number to a string using the Int_to_Str function in the StrngTTT unit. Example USES CRT,FASTTTT; CONST HEADING = 'TOOLKIT'; VAR NAME: STRING; BEGIN NAME := 'BOB ''TECHNOJOCK'' AINSBURY'; WRITEAT(1,25,YELLOW,RED,'PRESS F1 FOR HELP'); WRITEAT(36,1,LIGHTGREEN,BLACK,HEADING); WRITEAT(1,5,LIGHTCYAN,BLACK,NAME); WRITEAT(60,20,WHITE,BLACK,'HELLO '+'THERE!'); END. The example writes various strings to the screen, and illustrates that string constants/variables and concatenated strings are valid. !SEEALSO:Fastwrite PlainWrite WriteVert !SHORT:WriteBetween Write text centered between two points WriteBetween FastTTT Purpose To write text centered between two points. Declaration WriteBetween(X1,X2,Y,F,B: integer; ST: string); X1 is the left most X coord (1..79) X2 is the right most X Coord (2..80) Y is the Y coord or line number (1..25) F is the foreground (0..15) B is the background (0..15) ST is the string or text to be displayed Uses FastTTT. Remarks If the length of the string is greater than the distance between the X coordinates, the string will simply be written commencing at X1. Example USES FASTTTT; BEGIN WRITEBETWEEN(1,40,15,0,'LEFT SIDE'); WRITEBETWEEN(41,80,14,0,'RIGHT SIDE'); END. !SEEALSO:WriteCenter WriteAT !SHORT:WriteCenter Write text on the center of a line WriteCenter FastTTT Purpose To write text on the center of a line Declaration WriteCenter(Y,F,B: integer; ST: string); Y is the Y coord or line number (1..25) F is the foreground color (0..15) B is the background color (0..15) ST is the string or text to be displayed Uses FastTTT. Remarks The same rules apply as for WriteAT e.g. no reals/integers, strings may be concatenated etc. Example USES FASTTTT; BEGIN WRITECENTER(1,13,0,'MAJOR HEADING'); END. !SEEALSO:WriteAT WriteBetween !SHORT:WriteVert Write a string vertically WriteVert FastTTT Purpose To write a string vertically. Declaration WriteVert(X,Y,F,B: integer; ST: string); X is X coord of first character in string (1..25) Y is Y coord of first character in string (1..80) F is the foreground color B is the background color ST is the string or text to be displayed Uses FastTTT. Remarks This odd little procedure will write a string down the screen rather than across the screen. If the string is too long to fit on the screen, it will be truncated. Example Uses FastTTT; BEGIN WRITEVERT(10,5,15,0,'Y AXIS'); END.