{+++++++++++++++++++++++++++++++++++++++++++++} {+ get2c() gets two characters for the user. +} {+ A "look ahead" char and a current char. +} {+ +} {+ As a minimum you need these declarations +} {+ in your main program. +} {+++++++++++++++++++++++++++++++++++++++++++++} TYPE charname = (lletter, uletter, digit, blank, quote, atab, EndOfLine, FileMark, otherchar ); charinfo = RECORD name : charname; valu : char END; VAR InChar, (* Character read in from File *) currchar, (* Current operative character *) nextchar : CharInfo; (* Look-ahead character *) tab : char; stdin : TEXT; { standard input file } xeof, { End of File flag } xeoln :BOOLEAN; { End of Line flag } Procedure Initialize; begin { initialize the look ahead char } nextchar.name := blank; nextchar.valu := space; End{ of Initialize }; Procedure get2c({ updating }var nextchar : charinfo; { returning}var currchar : charinfo ); { last revised JUL 7, 80/rep } begin {+++++++++++++++++++++++++++++++++++++++++++++} { Terminator status module. } { Stores terminator status "AFTER" a read. } { NOTE this play on words - after one char is } { actually "PRIOR TO" the next character } {+++++++++++++++++++++++++++++++++++++++++++++} xeoln := EOLN(stdin); xeof := EOF(stdin); {+ Read byte module +} If not xeof then Read(stdin, look); {+ current operative character module +} currchar := nextchar; With NextChar Do begin(* Look-ahead character name module *) IF xeof then name := FileMark Else If xeoln then name := EndOfLine Else If LooK IN ['a'..'z'] then (* lower case *) name := lletter Else If LooK IN ['A'..'Z'] then (* upper case *) name := uletter Else If LooK IN ['0'..'9'] then (* digit *) name := digit Else If LooK = '''' then name := quote Else If LooK = TAB then name := atab Else If LooK = space then name := blank Else name := otherchar; CASE name of(* store character value module *) EndOfLine, FileMark: Valu := space; Else: Valu := LooK End { store character value module } End(* look-ahead name module *) End {of get2c};  space; Else: Valu := LooK End { store character value module } End(* look-ahead name module *) End {of get2c};