# Getting Runtime error 2 in Pascal Program

Page 1 of 1

## 1 Replies - 5051 Views - Last Post: 06 September 2012 - 04:31 AMRate Topic: //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'http://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=290030&amp;s=ac7365e21c6363d3e1335b16dbaa9d2a&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

### #1 repmeer

Reputation: 0
• Posts: 1
• Joined: 26-August 12

# Getting Runtime error 2 in Pascal Program

Posted 26 August 2012 - 03:55 AM

I trying to solve this puzzle:

LOCK + CANAL + CACHE = HIDDEN

Each letter represents a number from 0 to 9. There is only one solution.

I have found some code somewhere else to solve a problem like these and made some modifications but when i run the program i get a runtime error 2. The code is written in Pascal.
Can someone tell what i'm doing wrong? I have very few programming experience.

```program Hidden;

{Solve the cryptogram   LOCK
CANAL
CACHE
-----
HIDDEN}

var l,o,c,k,a,n,h,e,i,d  :longint;
s,outstr :string;
fout :text;

procedure TryOne;
var x,y :longint;
begin
l:=ord(outstr[0])-48;
o:=ord(outstr[1])-48;
c:=ord(outstr[2])-48;
k:=ord(outstr[3])-48;
a:=ord(outstr[4])-48;
n:=ord(outstr[5])-48;
h:=ord(outstr[6])-48;
e:=ord(outstr[7])-48;
i:=ord(outstr[8])-48;
d:=ord(outstr[9])-48;
if 1001*l + 200*o + 20110*c + k + 2010*a + 100*n + 20*h + e
= 100000*h + 10000*i + 1100*d + 10*e + n
then begin
assign(fout,'HIDDEN.TXT'); append(fout);
writeln(fout,'l=',l);
writeln(fout,'o=',o);
writeln(fout,'c=',c);
writeln(fout,'k=',k);
writeln(fout,'a=',a);
writeln(fout,'n=',n);
writeln(fout,'h=',h);
writeln(fout,'e=',e);
writeln(fout,'i=',i);
writeln(fout,'d=',d);
writeln(fout);
writeln(fout,'   ',l,o,c,k);
writeln(fout,'   ',c,a,n,a,l);
writeln(fout,'   ',c,a,c,h,e);
writeln(fout,'--------');
writeln(fout,h,i,d,d,e,n);
writeln(fout);
writeln('   ',   l,o,c,k);
writeln('   ',  c,a,n,a,l);
writeln('   ',  c,a,c,h,e);
writeln('--------');
writeln(h,i,d,d,e,n);
close(fout);
end;
end;

procedure Permute_it(s :string);
var ss    :string;
i,len :integer;
begin
len:=length(s);
if (len=0) then
TryOne
else for i:=1 to len do
begin
outstr:=outstr+s[i];
ss:=s;
delete(ss,i,1);
Permute_it(ss);
Delete(outstr,length(outstr),1);
end;
end;

begin
outstr:='';
s:='0123456789';
Permute_it(s);
end.
```

Is This A Good Question/Topic? 0

## Replies To: Getting Runtime error 2 in Pascal Program

### #2 turboscrew

Reputation: 133
• Posts: 889
• Joined: 03-April 12

## Re: Getting Runtime error 2 in Pascal Program

Posted 06 September 2012 - 04:31 AM

What kind of Pascal is this?
I have used Pascal some decades ago, but this doesn't look familiar.