How to solve the error on pascal pogram?

the statement of 'enter ID as A123456(9), empty to quit' shown if I enter a valid input (y0525330).
how to solve this?
thanks for helping.

the code is shown below:

program checkdigit;
temp,letter : integer;
HKID : string;

writeln('enter ID as A123456(9), empty to quit');
until (length(HKID)=8) and (HKID[1] in ['A'..'Z','a'..'z']) and (HKID[2] in ['0'..'9']) and (HKID[3] in ['0'..'9']) and (HKID[4] in ['0'..'9']) and (HKID[5] in ['0'..'9']) and (HKID[6] in ['0'..'9']) and (HKID[7] in ['0'..'9']) and (HKID[8] in ['0'..'9']) and (HKID[9] in ['0'..'9','A','a']);
if (length(HKID)>8) or (not (HKID[1] in ['A'..'Z','a'..'z'])) or (not (HKID[2] in ['0'..'9'])) or (not (HKID[3] in ['0'..'9'])) or (not (HKID[4] in ['0'..'9'])) or (not (HKID[5] in ['0'..'9'])) or (not (HKID[6] in ['0'..'9'])) or (not (HKID[7] in ['0'..'9'])) or (not (HKID[8] in ['0'..'9'])) or (not (HKID[9] in ['0'..'9','A','a']))
then Writeln('Wrong format, try again');
if (HKID[1]='a')or(HKID[1]='A') then letter:=1;
if (HKID[1]='b')or(HKID[1]='B') then letter:=2;
if (HKID[1]='c')or(HKID[1]='C') then letter:=3;
if (HKID[1]='d')or(HKID[1]='D') then letter:=4;
if (HKID[1]='e')or(HKID[1]='E') then letter:=5;
if (HKID[1]='f')or(HKID[1]='F') then letter:=6;
if (HKID[1]='g')or(HKID[1]='G') then letter:=7;
if (HKID[1]='h')or(HKID[1]='H') then letter:=8;
if (HKID[1]='i')or(HKID[1]='I') then letter:=9;
if (HKID[1]='j')or(HKID[1]='J') then letter:=10;
if (HKID[1]='k')or(HKID[1]='K') then letter:=11;
if (HKID[1]='l')or(HKID[1]='L') then letter:=12;
if (HKID[1]='m')or(HKID[1]='M') then letter:=13;
if (HKID[1]='n')or(HKID[1]='N') then letter:=14;
if (HKID[1]='o')or(HKID[1]='O') then letter:=15;
if (HKID[1]='p')or(HKID[1]='P') then letter:=16;
if (HKID[1]='q')or(HKID[1]='Q') then letter:=17;
if (HKID[1]='r')or(HKID[1]='R') then letter:=18;
if (HKID[1]='s')or(HKID[1]='S') then letter:=19;
if (HKID[1]='t')or(HKID[1]='T') then letter:=20;
if (HKID[1]='u')or(HKID[1]='U') then letter:=21;
if (HKID[1]='v')or(HKID[1]='V') then letter:=22;
if (HKID[1]='w')or(HKID[1]='W') then letter:=23;
if (HKID[1]='x')or(HKID[1]='X') then letter:=24;
if (HKID[1]='y')or(HKID[1]='Y') then letter:=25;
if (HKID[1]='z')or(HKID[1]='Z') then letter:=26;
temp := letter * 8 + ord(HKID[2]) * 7 + ord(HKID[3]) * 6 + ord(HKID[4]) * 5 + ord(HKID[5]) * 4 + ord(HKID[6]) * 3 + ord(HKID[7]) * 2 + ord(HKID[8]) * 1;
if (temp mod 11 = 0)
then writeln( 'The HKID is correct.' )
else writeln( 'The HKID is wrong.' );

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!