
{*************************************}
{*  This Procedure will take input   *}
{*  from the screen in a position    *}
{*  specified by vertical position   *}
{*  ,horizontal position. A maximum  *}
{*  character length must also be    *}
{*  passed.                          *}
{*************************************}


PROCEDURE CKLENGTH(VERT,HORZ,LENGTH:BYTE);

TYPE  STRING80 = ARRAY [1..80] OF CHAR;
VAR I : 1..80;
   FLAG : BYTE;
   INPSTRING : CHAR;
   ASC : BYTE;
   WORKSTRING : STRING[80];
BEGIN
REPEAT
  GOTOXY(VERT,HORZ); WRITE(LENGTH,' Characters Maximum Length');

    ASC:=0;      I:=0;WORKSTRING:='';INPSTRING:=CHR(32);
   GOTOXY(VERT,HORZ+1);WRITE('[');
     FOR FLAG:=1 TO LENGTH DO WRITE(' ');
     WRITE(']'); GOTOXY(VERT+1,HORZ+1);
       REPEAT
        READ(KBD,INPSTRING);
        IF INPSTRING = #8 THEN     {** Backspace **}
         BEGIN
          GOTOXY(VERT+I,HORZ+1); WRITE(' ');
          GOTOXY(VERT+I,HORZ+1);
          I:=I-1;
         END
        ELSE
         BEGIN
          I:=I+1;
          GOTOXY(VERT+I,HORZ+1);       WRITE(INPSTRING);
          WORKSTRING:=WORKSTRING+INPSTRING;
          ASC:=ORD(INPSTRING);
         END;
        IF ASC=13 THEN I:=I-1;
       UNTIL (ASC=13) OR (I=LENGTH+1);
      IF I>LENGTH THEN  WRITE(CHR(7));
    UNTIL (ASC=13);
END;

{* MAIN DRIVER *}
BEGIN
 CLRSCR;
  {** Pass Column, Row, &  Max Number of Characters **}
 CKLENGTH(3,4,10);
END.