Category : Pascal Source Code
Archive   : GENINPUT.ZIP
Filename : GENINPUT.PAS

 
Output of file : GENINPUT.PAS contained in archive : GENINPUT.ZIP
{ GENINPUT.PAS
By Roland "Bud" Brown
Written to be shared with my friends in PROG_CON and anyone else
that wants to use it.

This is a generalized input routine which uses the length of the string
passed to it and returns the same length of string to the calling routine
limits input to that length. Masked imput set true cause the routine to
skip any - character in the string for use in entering phone numbers date
etc (eg " - - " ) would be passed to this in the Input string and
the operator would have the hypens entered automatically.

You invoke this routine as :
Inputit(1,10,String_To_Be_entered,True);

This would be input String_To_Be_entered at line 10 column 1 and it IS
masked string (like ???-???-????) for a phone number.

Now, if you want a different foreground/background from normal text you
should set the variable fore and bckgnd before comming here they will be
intially set to a black character on a white backgound.

Left arrow is non destructive back spacing.
Right arrow moves cursor forward.
Back space key IS destructive.

It is up to the routine which calls geninput to determine how to
handle the other special keys. You can modify geninput to go to the
beginning of the data entry field on Home, to the end on the End key
add your own routines to handle any of the other special key combinations:
like Ctrl PgUp etc.

Currently GenInput exits on all the special keys it recognizes:
HOME
END
PGUP
PGDN
UP ARROW
DOWN ARROW
AND ALL FUNCTION KEYS
GenInput expects the calling routine to handle those conditions and sets
the appropriate flag and returns. The calling routine can check the
flag and perform the desired funtion. Geninput also does not have
INS mode or use the DEL key.

In short this is a beginning which you can modify to your hearts
delight - Enjoy!!

}

{ GENINPUT.PAS (a TP Unit for generalized Keyboard Input)
By Roland "Bud" Brown

Written to be shared with my friends in PROG_CON or anyone else
who would like to use it.

}
Unit GenInput;

Interface
Uses CRT;

Type

InputString = String[254];

VAR
F1,F2,F3,F4,F5,F6,F7,F8,F9,F10,PgUp,PgDn,HomeKey,EndKey,
UpArrow,DnArrow:Boolean;
Fore,Bckgnd,SaveAttr:byte;


Procedure Inputit(x,y:Integer; var Input:INputString; MaskedInput:Boolean);

Implementation

Procedure Inputit;

Type
Control = (New,Up,Down);



Var
Scrl:Control;
Xlength,CrrntX,CrrntY,EndLedger,StrngLength:Integer;
InputChar:Char;
BackupFlag:Boolean;



Procedure MoveRight;
Begin
BackupFlag:=True;
x:=x+1;
Xlength:=Xlength+1;
If (Input[Xlength]='-') and (XLength<=StrngLength)
and (MaskedInput) then MoveRight;
End;


Procedure Backup;

Begin
BackupFlag:=True;
If CrrntX < x then x:=x-1;
Xlength:=Xlength-1;
If Xlength < 1 Then Xlength:=1;
If (Input[Xlength]='-') And (Xlength<> 1) and (MaskedInput) then Backup;
End;


Procedure RealBackup;

Begin
BackUp;
Input[Xlength]:=' ';
Gotoxy(x,y); Write(' ');
End;


Procedure ReadIBM;
Var
IBMChar:Char;

Begin
BackupFlag:=False;
If KeyPressed then
Begin
IBMChar:=ReadKey;
Case IBMChar of
';': F1:=TRUE;
'<': F2:=TRUE;
'=': F3:=TRUE;
'>': F4:=TRUE;
'?': F5:=TRUE;
'@': F6:=TRUE;
'A': F7:=TRUE;
'B': F8:=TRUE;
'C': F9:=TRUE;
'D': F10:=TRUE;
'K': Backup; {Left Arrow}
'M': MoveRight;
'H': UpArrow:=TRUE;
'P': DnArrow:=TRUE;
'G': HomeKey:=TRUE;
'O': EndKey:=TRUE;
'I': PgUp:=TRUE;
'Q': PgDn:=TRUE;
End;
If not BackupFlag then
Xlength:=StrngLength+1; {Some Special key pressed so get out}
End;
If KeyPressed then ReadIBM;
End;



{***********PROCEDURE INPUTIT BEGINS AT THIS POINT*****************}

Begin
SaveAttr:=TextAttr;
F1:=False;
F2:=False;
F3:=False;
F4:=False;
F5:=False;
F6:=False;
F7:=False;
F8:=False;
F9:=False;
F10:=False;
HomeKey:=False;
EndKey:=False;
PgUp:=False;
PgDn:=False;
UpArrow:=False;
DnArrow:=False;
BackupFlag:=False;
CrrntX:=x;
Xlength:=1;
CrrntY:=y;
StrngLength:= Length (Input);
TextColor(Fore);
TextBackGround(Bckgnd);
Gotoxy(Crrntx,Crrnty);
Write(Input);
Repeat
BackupFlag:=False;
GotoXY(x,y);
InputChar:=ReadKey;
If InputChar <> #13 Then
Begin
If InputChar <> #26 Then
Begin
Case InputChar of
#00:ReadIBM;
#08:RealBackup;
Else
Delete(Input,Xlength,1);
Insert(InputChar,Input,Xlength);
Gotoxy(x,y);
Write(InputChar);
x:=x+1;
Xlength:=Xlength+1;
If (Input[Xlength]='-') and (Xlength<>1) and (Xlength and (MaskedInput) Then MoveRight;
End;
End;
End;
If InputChar=#13 then Xlength:=StrngLength+1;
If Inputchar=#26 then Xlength:=StrngLength+1;
Until Xlength = StrngLength+1;
TextAttr:=SaveAttr;
End;

Begin
fore:=Black;
Bckgnd:=White;
End.



  3 Responses to “Category : Pascal Source Code
Archive   : GENINPUT.ZIP
Filename : GENINPUT.PAS

  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/