PROGRAM Convert(Input, Output);

    { Program 8.1 - Read a sequence of digits and convert
      them to the integer they represent.
      Assume no leading sign. }

    VAR
        Ch: Char;
        Digits: SET OF '0'..'9';
        Number: Integer;
BEGIN
    Digits := ['0'..'9'];   { initialize value of the set }
    Read(Input, Ch);
    Number := 0;
    WHILE Ch IN Digits DO
    BEGIN
        Number := Number * 10 + Ord(Ch) - Ord('0');
        WriteLn(Output, Number);
        Read(Input, Ch);
    END                     { Ch contains the character following the integer }
END.
