Category : Science and Education
Archive   : WDBDISK5.ZIP
Filename : FGREADLN.INC

 
Output of file : FGREADLN.INC contained in archive : WDBDISK5.ZIP
{ Procedure FGREADLN is designed to be used in place of the normal Pascal
READLN function. It uses the Flexi-Graph standard font size 1 characters
(therefore the value of 8 is added and subtracted from the 'X' coordinate).
If larger sized characters are use then the value of 8 must be multiplied
by the size selected for the characters.

This routine represents a basic graphics mode text input capability and was
kept simple so as to clearly illustrate the fundamental concepts. Once a
basic understanding is obtained, the routine can be modified to support
different size characters, other fonts, etc.

In order to avoid damaging the graphics display which is on the CRT this
routine assumes that the calling program is in the toggle pixel mode.
Using the toggle mode allows this, and the calling program, to write
text prompts to the CRT without having to worry about whether the prompt
and response overlap any of the graphics image.

Only basic Pascal capabilities and constructs were use so as to lessen the
work of adapting this routine to other languages. }


PROCEDURE FGREADLN(VAR INSTRING : FGSTRING);

CONST
CR = 13;
BACK_SPACE = 8;

VAR
INT_CHAR : INTEGER; {integer form of the input character}
STATUS : INTEGER; {holds console status}
X, Y : INTEGER; {used to store current cursor position}
XSTART, YSTART : INTEGER; {used to store initial cursor position}
INCHAR : CHAR; {holds character format if input character}

BEGIN
FGXYAT(XSTART, YSTART); {save initial cursor position}
INSTRING := ' '; {set the sting to one blank}
DELETE(INSTRING,1,1); {delete the first character in the string}
REPEAT FGCONS(STATUS) {wait for the first character to be entered}
UNTIL STATUS = -1;
FGCONI(INT_CHAR); {get the first character in integer format}
INCHAR := CHR(INT_CHAR); {convert input to character format}

WHILE ( (INT_CHAR <> CR) AND (ORD(INSTRING.LEN) < 80) ) DO {process INPUT}
BEGIN

IF INCHAR IN [' '..'~'] THEN {check for ASCII character}
BEGIN
CONCAT(INSTRING, INCHAR); {add character to end of string}
FGTYPE(1,0,1,INCHAR); {display the character}
END
ELSE
IF (INT_CHAR = BACK_SPACE) {check for backspace}
AND (ORD(INSTRING.LEN) > 0) {and at least one char in string}
THEN
BEGIN
FGXYAT(X,Y); {get current position}
FGMOVE(X-8, Y); {backup 8 pixels}
FGTYPE(1,0,1,INSTRING[ORD(INSTRING.LEN)]); {type/toggle last char}
FGMOVE(X-8,Y); {backup 8 pixels}
DELETE(INSTRING, ORD(INSTRING.LEN), 1); {delete last char in string}
END;

REPEAT FGCONS(STATUS) {wait for next character}
UNTIL STATUS = -1;
FGCONI(INT_CHAR); {read next character}

INCHAR := CHR(INT_CHAR); {convert to character format}
END;

FGMOVE(XSTART, YSTART); {move to beginning of the string}
{LINCLR(0); }
FGTYPE(1,0,ORD(INSTRING.LEN),INSTRING[1]); {type/toggle out whole string}
FGMOVE(XSTART, YSTART); {move to beginning of the string}
{LINCLR(7);}
END;



  3 Responses to “Category : Science and Education
Archive   : WDBDISK5.ZIP
Filename : FGREADLN.INC

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/