home *** CD-ROM | disk | FTP | other *** search
- {$V-}
- program Test_Get_Data;
- type
- string255 = string[255];
- var
- filename : string[66];
- NumStrin : string[20];
- AlphaStr : string[60];
- ExistStr : string[50];
- GoingUp : boolean;
- (* ================================================================ *)
-
- type
- charset = set of char;
- regpack = record
- ax,bx,cx,dx,bp,si,di,ds,es,flags: integer;
- end;
- Screen = array[1..25] of array[1..80] of integer;
- ScrPt = ^screen;
-
- const
- CR = #13;
- BS = #8;
- ESC = #27;
- space = #32;
- Ctrl_BS = #127;
- numbers : charset = ['0'..'9'];
- alpha : charset = ['A'..'Z','a'..'z'];
- special : charset = [CR, BS, Esc, Space, Ctrl_BS];
- fname : charset = ['^'..'~', '@'..'Z', '0'..':', '!', '#'..')', '\'];
- BlueBlak : byte = $09;
- WhitBlak : byte = $70;
- BlakWhit : byte = $0F;
- Atention : byte = $8F;
- var
- display : ScrPt;
- regs : regpack;
- VidMode, NumCols : byte;
- VidOffset, GlobVar : integer;
- SaveFace, JustOne, Again : boolean;
-
- PROCEDURE CheckColor;
- BEGIN
- WITH regs DO
- BEGIN
- AX := 15 SHL 8;
- Intr($10, regs);
- vidmode := AX AND $00FF;
- END;
- IF vidmode = 7 THEN
- BEGIN
- Display := Ptr($B000, $0000);
- END
- ELSE
- BEGIN
- Display := Ptr($B800, $0000);
- END;
- END;
-
-
-
-
- PROCEDURE MakeCurrent(XAtt : Byte);
- BEGIN
- TextColor((Xatt AND $F)+16*(XAtt SHR 7));
- TextBackground((XAtt AND $70) SHR 4);
- END;
-
- FUNCTION rep(CH : Char; NM : Byte) : string255;
- {----------------------------------------------------------------}
- { Output is a string of NM repetitions of character CH. We do }
- { it with FillChar for speed, but we must check that we don't }
- { accidentally "spill out" of the variable's allocated space. }
- {----------------------------------------------------------------}
- VAR
- temp : string255;
- BEGIN
- IF NM > SizeOf(temp)-1 THEN NM := SizeOf(temp)-1;
- FillChar(temp[1], NM, CH);
- temp[0] := Chr(NM);
- rep := temp;
- END;
-
- procedure beep;
- begin
- write(#7); {replace}
- end;
-
- PROCEDURE PutanAtt(Co, Ro, Att : Byte);
- (* =============================================================== *)
- (* PURPOSE: Puts a character and attribute (coded as an integer) *)
- (* at the POSition CO(lumn) RO(w) -- high byte is attribute, low *)
- (* is character. The INLINE code is used to prevent "snow" *)
- (* created by reading and writing directly to the screen memory *)
- (* in color mode. Technically we are waiting for the Horizontal *)
- (* Retrace.} *)
- (* =============================================================== *)
-
- BEGIN
- IF vidMode = 7 THEN
- display^[ Ro][Co] := (display^[Ro][Co] AND $FF) OR (Att SHL 8)
- ELSE
- BEGIN
- VidOffset := (ro-1)*160+(co-1)*2+1;
- GlobVar := Att;
- {.F-}
- INLINE(
- $A1/GlobVar/ { MOV AX,GlobVar } { Put the char/att in AX &}
- { offset in BX BEFORE }
- $8B/$1E/VidOffset/ { MOV BX,VidOffset} { messing with DS. }
- $1E/ { PUSH DS } { Save the "real" DS. }
- $50/ { PUSH AX } { Save the char/att }
- $B8/$B800/ { MOV AX,0B800h } { Set the DS to B800 (the }
- $8E/$D8/ { MOV DS,AX } { color vid memory }
- $BA/$DA/$03/ { MOV DX,03DA } { Set DX to ColorVid port }
- { XX001:}
- $EC/ { IN AL,DX } { Loop 'til the port goes }
- $A8/$01/ { TEST AL,01 } { to zero. }
- $75/$FB/ { JNZ XX001 }
- $FA/ { CLI } { NO INTERRUPTS NOW! }
- { XX002:}
- $EC/ { IN AL,DX } { Loop 'til the port goes }
- $A8/$01/ { TEST AL,01 } { high again. }
- $74/$FB/ { JZ XX002 }
- $58/ { POP AX } { Get back the char/att & }
- $88/$07/ { MOV [BX], AL } { poke it into memory at }
- { offset BX }
- $1F/ { POP DS } { Get back the "real" DS }
- $FB); { STI } { Re-enable interrupts }
- END;
- {.F+}
- END; { procedure PutAnAtt(C,R,A:byte}
-
-
-
-
-
-
- PROCEDURE GetSafely(VAR getWhat : string255; X, Y, L : Byte; range : charset;
- ATT1,ATT2 : Byte; VAR Back : Boolean);
- VAR
- CH, DH : Char;
- BEGIN
- MakeCurrent(Att1);
- Back := False;
- GoToXY(X, Y);
- Write(rep(' ', L));
- GoToXY(X, Y);
- Write(GetWhat);
- REPEAT
- REPEAT
- REPEAT UNTIL KeyPressed;
- DH := #0;
- Read(Kbd, CH);
- IF (ch = #27) AND KeyPressed THEN
- Read(Kbd, DH);
- UNTIL (CH IN (range+special)) OR (DH = 'H');
- IF DH <> #0 THEN
- BEGIN
- CASE DH OF
- 'H' : BEGIN
- Back := True;
- CH := #13;
- END;
- 'P' : CH := #13;
- ';' : ; { Give 'em some help? }
- END;
- END
- ELSE
- BEGIN
- CASE CH OF
- #8 : IF Length(GetWhat) > 0 THEN
- BEGIN
- GoToXY(WhereX-1, Y);
- Write(' ');
- GoToXY(WhereX-1, Y);
- GetWhat[0] := Pred(GetWhat[0]);
- END;
- #13 :;
- #27 : BEGIN
- ClrScr;
- WriteLn('Program aborted by user');
- halt;
- END;
- #127 : BEGIN
- GoToXY(X, Y);
- Write(rep(' ', Length(GetWhat)));
- GoToXY(X, Y);
- GetWhat := '';
- END;
- ELSE
- IF Length(GetWhat) < L THEN
- BEGIN
- GetWhat := GetWhat+CH;
- Write(CH);
- END
- ELSE beep;
- END;
- END;
- UNTIL (CH = #13);
- while GetWhat[length(GetWhat)] = ' ' DO
- IF GetWhat[0] > #0 THEN
- GetWhat[0] := pred(GetWhat[0]);
- MakeCurrent(Att2);
- GoToXY(X, Y);
- Write(rep(' ', L));
- GoToXY(X, Y);
- Write(GetWhat);
- END;
-
-
-
-
-
- PROCEDURE Show_Pick(Y, X1, X2, AT, BK : Byte; cherce : Boolean);
- BEGIN
- IF Cherce THEN
- BEGIN
- PutAnAtt(X1, Y, AT);
- PutAnAtt(X2, Y, BK);
- END
- ELSE
- BEGIN
- PutAnAtt(X2, Y, AT);
- PutAnAtt(X1, Y, BK);
- END;
- END;
-
-
- PROCEDURE Get_Pick(Y, X1, X2, AT, BK : Byte; VAR cherce, Back : Boolean);
- VAR
- CH, DH : Char;
- BEGIN
- Back := False;
- GoToXY(X1, Y);
- Show_Pick(Y, X1, X2, atention, BK, cherce);
-
- REPEAT
- REPEAT UNTIL KeyPressed;
- DH := #0;
- Read(Kbd, CH);
- IF (CH = #27) THEN
- BEGIN
- if KeyPressed THEN
- BEGIN
- Read(Kbd, DH);
- CASE DH OF
- ';' : ; {Give 'em some help?}
- 'H' : BEGIN
- Back := True;
- CH := #13;
- END;
- 'K' : cherce := True;
- 'M' : cherce := False;
- 'P' : CH := #13;
- END;
- END
- ELSE
- BEGIN
- ClrScr;
- WriteLn('Program aborted by user');
- halt;
- END;
- END
- ELSE
- IF CH = #9 THEN cherce := NOT cherce;
- Show_Pick(Y, X1, X2, Atention, BK, cherce);
- UNTIL CH = #13;
- SHow_Pick(Y, X1, X2, AT, BK, cherce);
- END;
- (* ================================================================ *)
-
- procedure Get_Data;
- label
- 1,2,3,4,5,6 ;
- begin
- 1: GetSafely(filename,11,5,66,fname,BlueBlak,WhitBlak,goingUp);
- IF goingUp THEN goto 1;
- 2: GetSafely(NumStrin,11,6,20,numbers,BlueBlak,WhitBlak,goingUp);
- IF goingUp THEN goto 1;
- 3: GetSafely(AlphaStr,13,7,60,alpha,BlueBlak,WhitBlak,goingUp);
- IF goingUp THEN goto 2;
- 4: GetSafely(ExistStr,18,8,50,alpha+numbers+['!',','],BlueBlak,WhitBlak,goingUp);
- IF goingUp THEN goto 3;
- 5: Get_Pick(10,23,25,BlueBlak,WhitBlak,SaveFace,goingUp);
- IF goingUp THEN goto 4;
- 6: Get_Pick(11,23,28,BlueBlak,WhitBlak,JustOne,goingUp);
- IF goingUp THEN goto 5;
- end;
-
- procedure Show_Data;
- begin
- GotoXY(11,5); write(filename);
- GotoXY(11,6); write(numStrin);
- GotoXY(13,7); write(AlphaStr);
- GotoXY(18,8); Write(ExistStr);
- Show_Pick(10,23,25,BlueBlak,WhitBlak,SaveFace);
- Show_Pick(11,23,28,BlueBlak,WhitBlak,JustOne);
- end;
-
- procedure Initialize;
- begin
- filename := '';
- NumStrin := '';
- AlphaStr := '';
- ExistStr := 'Three Cheers! 1, 2, 3!!!';
- SaveFace := false;
- JustOne := true;
- Again := true;
- end;
-
-
- begin
- Initialize;
- CheckColor;
- MakeCurrent(WhitBlak);
- While again DO
- begin
- ClrScr;
- WriteLn(' DATA ENTRY DEMO ');
- GotoXY(1,5);
- Write('FILENAME: ');
- GotoXY(1,6);
- Write('A NUMBER: ');
- GotoXY(1,7);
- write('ALPHA ONLY: ');
- GotoXY(1,8);
- Write('EXISTING STRING: ');
- GotoXY(11,10);
- Write('SAVE FACE? <Y/N> ');
- GotoXY(11,11);
- write('HOW MANY? <1 or 2> ');
- Show_Data;
- Get_Data;
- GotoXY(30,15);
- Write('AGAIN? (Y/N)');
- Show_Pick(15,38,40,BlueBlak,WhitBlak,again);
- Get_Pick(15,38,40,BlueBlak,WhitBlak,again,goingUp);
- end;
-
- end.