Your code does not compile:
kevan$ gpc p.pas p.pas: In main program: p.pas:20: error: undeclared identifier `CH' (first use in this routine) p.pas:20: error: (Each undeclared identifier is reported only once p.pas:20: error: for each routine it appears in.)