Jv>> Do it this way and it will work and it's much easyer to understand:
Jv>> const
Jv>> Key = ['O'..'9', '*', '#' ];
Jv>> var
Jv>> userinput : char;
Jv>> begin
Jv>> Read(userinput);
Jv>> if userinput in Key then
BS> The problem with doing it that way - at least with Turbo Pascal 7 - is
BS> that the code generated wastes time re-constructing that set of
BS> characters every time you hit it. Slowly, too - it adds the characters
BS> to the set one-by-one. If your test is inside a loop, that may not be a
BS> wise thing to do.
I thought that TP7 did optimize the sets, but I may be wrong.
Anyhow, how long will it take on , say, a 90 MHz Pentium to
construct the set above compared to the time for the line
Read(userinput);
Jud McCranie
* Silver Xpress V4.3 SW20178
--- PCBoard (R) v15.3/M 5
---------------
* Origin: Riverdale, Ga (1:133/9024)
|