home *** CD-ROM | disk | FTP | other *** search
- Unit STI_INPT;
- {$I-}
- interface
-
- Uses STI_STRN,STI_SCRF, Crt;
-
- function STI_GetStringXY(X,Y,Length,Color,Attr : byte; Legal : string) : string;
- function STI_GetByteXY1(X,Y,Min,Max,Color,Attr : byte) : byte;
- function STI_GetByteXY2(X,Y,Min,Max,Color,Attr : byte) : byte;
- function STI_GetWordXY1(X,Y : byte; Min,Max : word; Color,Attr : byte) : word;
- function STI_GetWordXY2(X,Y : byte; Min,Max : word; Color,Attr : byte) : word;
- function STI_GetIntXY1(X,Y : byte; Min,Max : integer; Color,Attr : byte) : integer;
- function STI_GetIntXY2(X,Y : byte; Min,Max : integer; Color,Attr : byte) : integer;
- function STI_GetLongIntXY1(X,Y : byte; Min,Max : LongInt; Color,Attr : byte) : LongInt;
- function STI_GetLongIntXY2(X,Y : byte; Min,Max : LongInt; Color,Attr : byte) : LongInt;
- function STI_GetShortIntXY1(X,Y : byte; Min,Max : ShortInt; Color,Attr : byte) : ShortInt;
- function STI_GetShortIntXY2(X,Y : byte; Min,Max : ShortInt; Color,Attr : byte) : ShortInt;
- function STI_GetRealXY(X,Y,Width : byte; Min,Max : Real; Color,Attr : byte) : Real;
-
-
-
- implementation
-
- {---------------------------------------------------------------------------}
-
- function STI_GetStringXY(X,Y,Length,Color,Attr : byte; Legal : string) : string;
-
- var
- temp : string;
- loop : byte;
- inch : char;
- dumm : byte;
- OldAttr : byte;
-
- begin
- OldAttr := TextAttr;
- TextColor(Color+Attr);
- TextColor(Color+Attr);
- GotoXY(X,Y);
- if (X+Length) > 79 then Length := (79-X);
- temp := MakeStr(Length,32);
- Write(temp);
- loop := 1;
- inch := ' ';
- while inch <> #13 do
- begin
- repeat until keypressed;
- inch := readkey;
- if (pos(inch,legal) > 0) or (inch < #31) then
- begin
- case inch of
- #8 : begin
- dec(loop);
- if loop < 1 then loop := 1;
- for dumm := loop to Length-1 do
- begin
- temp[dumm] := temp[dumm+1];
- end;
- temp[Length] := ' ';
- GotoXY(X,Y);
- Write(temp);
- GotoXY(X+Loop-1,Y);
- end;
- #10 : begin
- inc(loop);
- if loop > Length then Loop := Length;
- for dumm := loop to Length-1 do
- begin
- temp[dumm+1] := temp[dumm];
- end;
- GotoXY(X,Y);
- Write(temp);
- GotoXY(X+Loop-1,Y);
- end
- else if inch > #31 then
- begin
- temp[loop] := Inch;
- GotoXY(X,Y);
- Write(temp);
- Inc(Loop);
- if Loop > Length then Loop := Length;
- GotoXY(X+Loop-1,Y);
- end;
- end;
- end
- else
- Write(#7);
- end;
- STI_GetStringXY := copy(temp,1,loop);
- TextAttr := OldAttr;
- end;
-
- {---------------------------------------------------------------------------}
-
- function STI_GetByteXY1(X,Y,Min,Max,Color,Attr : byte) : byte;
-
- Var
- Inch : char;
- Value : byte;
- OldAttr : byte;
-
- begin
- OldAttr := TextAttr;
- TextColor(Color+Attr);
- Inch := #0;
- Value := Min;
- while Inch <> #13 do
- begin
- GotoXY(X,Y); write(' ',value,' ');
- repeat until keypressed;
- Inch := readkey;
- case Inch of
- #8 : begin
- if Value > Min then Dec(Value);
- end;
- #12 : begin
- if Value < Max then Inc(Value);
- end;
- end;{case}
- end;
- STI_GetByteXY1 := Value;
- TextAttr := OldAttr;
- end;
-
- {---------------------------------------------------------------------------}
-
- function STI_GetByteXY2(X,Y,Min,Max,Color,Attr : byte) : byte;
-
- Var
- Dummy : string;
- Value : word;
- OldAttr : byte;
- Test : integer;
-
- begin
- OldAttr := TextAttr;
- TextColor(Color+Attr);
- repeat
- begin
- Dummy := STI_GetStringXY(X,Y,3,Color,Attr,'0123456789');
- RightTrimStr(Dummy);
- val(Dummy,Value,Test);
- if not((Value >= Min) and (Value <= Max)) then
- Write(#7);
- end;
- until ((Value >= Min) and (Value <= Max)) and (Test = 0);
- GotoXY(X,Y);
- Write(Value);
- STI_GetByteXY2 := Value;
- TextAttr := OldAttr;
- end;
-
- {---------------------------------------------------------------------------}
-
- function STI_GetWordXY1(X,Y : byte; Min,Max : word; Color,Attr : byte) : word;
-
- Var
- Inch : char;
- Value : word;
- OldAttr : byte;
-
- begin
- OldAttr := TextAttr;
- TextColor(Color+Attr);
- Inch := #0;
- Value := Min;
- while Inch <> #13 do
- begin
- GotoXY(X,Y); write(' ',value,' ');
- repeat until keypressed;
- Inch := readkey;
- case Inch of
- #8 : begin
- if Value > Min then Dec(Value);
- end;
- #12 : begin
- if Value < Max then Inc(Value);
- end;
- end;{case}
- end;
- STI_GetWordXY1 := Value;
- TextAttr := OldAttr;
- end;
-
- {---------------------------------------------------------------------------}
-
- function STI_GetWordXY2(X,Y : byte; Min,Max : word; Color,Attr : byte) : word;
-
- Var
- Dummy : string;
- Value : word;
- OldAttr : byte;
- Test : integer;
-
- begin
- OldAttr := TextAttr;
- TextColor(Color+Attr);
- repeat
- begin
- Dummy := STI_GetStringXY(X,Y,5,Color,Attr,'0123456789');
- RightTrimStr(Dummy);
- val(Dummy,Value,Test);
- if not((Value >= Min) and (Value <= Max)) then
- Write(#7);
- end;
- until ((Value >= Min) and (Value <= Max)) and (Test = 0);
- STI_GetWordXY2 := Value;
- TextAttr := OldAttr;
- end;
-
- {---------------------------------------------------------------------------}
-
- function STI_GetIntXY1(X,Y : byte; Min,Max : integer; Color,Attr : byte) : integer;
-
- Var
- Inch : char;
- Value : integer;
- OldAttr : byte;
-
- begin
- OldAttr := TextAttr;
- TextColor(Color+Attr);
- Inch := #0;
- Value := Min;
- while Inch <> #13 do
- begin
- GotoXY(X,Y); write(' ',value,' ');
- repeat until keypressed;
- Inch := readkey;
- case Inch of
- #8 : begin
- if Value > Min then Dec(Value);
- end;
- #12 : begin
- if Value < Max then Inc(Value);
- end;
- end;{case}
- end;
- STI_GetIntXY1 := Value;
- TextAttr := OldAttr;
- end;
-
- {---------------------------------------------------------------------------}
-
- function STI_GetIntXY2(X,Y : byte; Min,Max : integer; Color,Attr : byte) : integer;
-
- Var
- Dummy : string;
- Value : integer;
- OldAttr : byte;
- Test : integer;
-
- begin
- OldAttr := TextAttr;
- TextColor(Color+Attr);
- repeat
- begin
- Dummy := STI_GetStringXY(X,Y,5,Color,Attr,'-0123456789');
- RightTrimStr(Dummy);
- val(Dummy,Value,Test);
- if not((Value >= Min) and (Value <= Max)) then
- Write(#7);
- end;
- until ((Value >= Min) and (Value <= Max)) and (Test = 0);
- STI_GetIntXY2 := Value;
- TextAttr := OldAttr;
- end;
-
- {---------------------------------------------------------------------------}
-
- function STI_GetLongIntXY1(X,Y : byte; Min,Max : LongInt; Color,Attr : byte) : LongInt;
-
- Var
- Inch : char;
- Value : LongInt;
- OldAttr : byte;
-
- begin
- OldAttr := TextAttr;
- TextColor(Color+Attr);
- Inch := #0;
- Value := Min;
- while Inch <> #13 do
- begin
- GotoXY(X,Y); write(' ',value,' ');
- repeat until keypressed;
- Inch := readkey;
- case Inch of
- #8 : begin
- if Value > Min then Dec(Value);
- end;
- #12 : begin
- if Value < Max then Inc(Value);
- end;
- end;{case}
- end;
- STI_GetLongIntXY1 := Value;
- TextAttr := OldAttr;
- end;
-
- {---------------------------------------------------------------------------}
-
- function STI_GetLongIntXY2(X,Y : byte; Min,Max : LongInt; Color,Attr : byte) : LongInt;
-
- Var
- Dummy : string;
- Value : LongInt;
- OldAttr : byte;
- Test : integer;
-
- begin
- OldAttr := TextAttr;
- TextColor(Color+Attr);
- repeat
- begin
- Dummy := STI_GetStringXY(X,Y,11,Color,Attr,'-0123456789');
- RightTrimStr(Dummy);
- val(Dummy,Value,Test);
- if not((Value >= Min) and (Value <= Max)) then
- Write(#7);
- end;
- until ((Value >= Min) and (Value <= Max)) and (Test = 0);
- STI_GetlongIntXY2 := Value;
- TextAttr := OldAttr;
- end;
-
- {---------------------------------------------------------------------------}
-
- function STI_GetShortIntXY1(X,Y : byte; Min,Max : ShortInt; Color,Attr : byte) : ShortInt;
-
- Var
- Inch : char;
- Value : ShortInt;
- OldAttr : byte;
-
- begin
- OldAttr := TextAttr;
- TextColor(Color+Attr);
- Inch := #0;
- Value := Min;
- while Inch <> #13 do
- begin
- GotoXY(X,Y); write(' ',value,' ');
- repeat until keypressed;
- Inch := readkey;
- case Inch of
- #8 : begin
- if Value > Min then Dec(Value);
- end;
- #12 : begin
- if Value < Max then Inc(Value);
- end;
- end;{case}
- end;
- STI_GetShortIntXY1 := Value;
- TextAttr := OldAttr;
- end;
-
- {---------------------------------------------------------------------------}
-
- function STI_GetShortIntXY2(X,Y : byte; Min,Max : ShortInt; Color,Attr : byte) : ShortInt;
-
- Var
- Dummy : string;
- Value : ShortInt;
- OldAttr : byte;
- Test : integer;
-
- begin
- OldAttr := TextAttr;
- TextColor(Color+Attr);
- repeat
- begin
- Dummy := STI_GetStringXY(X,Y,4,Color,Attr,'-0123456789');
- RightTrimStr(Dummy);
- val(Dummy,Value,Test);
- if not((Value >= Min) and (Value <= Max)) then
- Write(#7);
- end;
- until ((Value >= Min) and (Value <= Max)) and (Test = 0);
- STI_GetShortintXY2 := Value;
- TextAttr := OldAttr;
- end;
-
- {---------------------------------------------------------------------------}
-
- function STI_GetRealXY(X,Y,Width : byte; Min,Max : Real; Color,Attr : byte) : Real;
-
- Var
- Dummy : string;
- Value : Real;
- OldAttr : byte;
- Test : integer;
-
- begin
- OldAttr := TextAttr;
- TextColor(Color+Attr);
- repeat
- begin
- Dummy := STI_GetStringXY(X,Y,Width,Color,Attr,'-0123456789.Ee');
- RightTrimStr(Dummy);
- val(Dummy,Value,Test);
- if not((Value >= Min) and (Value <= Max)) then
- Write(#7);
- end;
- until ((Value >= Min) and (Value <= Max)) and (Test = 0);
- STI_GetRealXY := Value;
- TextAttr := OldAttr;
- end;
-
- {---------------------------------------------------------------------------}
-
- begin
- end.
-
-
-