type
  Str8        = string[8];
var
  Date        : string[8];
procedure Get_Date (X,Y : integer; Prompt : Str80);
  var
    CurX, Pos : integer;
    Ch        : char;
  begin
    CurX := X + length(Prompt);
    Date := '__/__/__'; LowVideo;
    gotoXY(X,Y); write(Prompt);
    gotoXY(CurX,Y); write(Date); NormVideo; Cursor_On;
    gotoXY(CurX,Y); Pos := 1;
    InStr := 'DUMMY';
    repeat
      read(kbd,Ch);
      if (Ch = CR) and (Pos = 1) then
        begin
          InStr := ''; Date := ''; Exit
        end;
      if (Ch = ESC) and (Pos = 1) then
        begin
          InStr := ESC; Exit
        end;
      if ((Ch = BS) or (Ch = RUB)) and (Pos > 1) then
        begin
          if Pos in [4,7] then Pos := Pos - 2 else Pos := Pos - 1;
          Date[Pos] := '_'
        end
      else if ((Ch) in ['0'..'9']) and (Pos < 9) then
        begin
          Date[Pos] := Ch;
          if Pos in [2,5] then Pos := Pos + 2 else Pos := Pos + 1
        end;
      gotoXY(CurX,Y); write(Date); GotoXY(CurX + Pos - 1,Y);
    until (Ch = CR) and (Pos = 9);
  end;

function Int_Date (Str_Date : Str8) : Integer;
  var
    D1,D2,D7,D8,Code    : Integer;
  begin
    Val(Str_Date[1],D1,Code);
    Val(Str_Date[2],D2,Code);
    Val(Str_Date[7],D7,Code);
    Val(Str_Date[8],D8,Code);
    Int_Date :=  D7 * 1000 +
                 D8 * 100  +
                (D1 * 10   +
                 D2)* 8
  end;
