Pascal

Moderators: None (Apply to moderate this forum)
Number of threads: 4095
Number of posts: 14004

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
pascal can't find CTR.Tpu Posted by nikaoto on 23 Feb 2011 at 9:26 AM
hi,
guys.


i have a little problem with B.P.(also known as Borand Pascal.)
i created a program which is an RPG game.every time i try to compile it, it writes'file not found CTR.Tpu'.i think i don't have the file which is needed to compile the program.i've searched everywhere for the file but i just couldn't find it.Can anybody help me please???
heres the program:

program RPG;
uses
ctr, sysutlis,
cthreads,
classes
type
creature = record
Name:string;
Armor,Health,Magic,Power:integer;
end;
var
Hero, Dragon, Spider, LargeSpider, Opponent:creature;
enemNum:integer;
selection:string;
score:integer;
procedure LoadSettings;
begin
score := 0;
with Hero do
begin
Name:= 'hero nika';
Armor := 2;
Health :=10;
Magic := 2;
Power := 5;
end;
with Dragon do
begin
Name:= 'Dragon';
Armor := 3;
Health := 5;
Magic := 2;
Power := 4;
end;
with Spider do
begin
Name:= 'Spider';
Armor :=0;
Health :=1;
Magic :=0;
Power :=2;
end;
with LargeSpider do
begin
Name:= 'LargeSpider';
Armor :=4;
Health :=2;
Magic :=1;
Power :=3
end;
end;
procedure GetEnemy;
begin
randomize;
enemNum := random(3) + 1;
if enemNum = 1 then opponent:=Spider else if enemNum =2 then opponent :=LargeSpider;
end;
procedure WriteStats;
begin
with Hero do
begin
writeln(Name, ' score = ', score);
writeln('Health = ', Health);
writeln('Armor = ', Armor);
writeln('Magic = ',Magic);
writeln('Power = ',Power);
end;
writeln;
writeln;
with opponent do
writeln('Opponent ', Name);
writeln('Health = ', Health);
writeln('Armor = ',Armor);
writeln('Magic = ',Magic);
writeln('Power = ',Power);
end;
end;
procedure Menu;
begin
repeat writeln;
writeln('(F)ight');
writeln('(M)agic');
write('Selection: ');
readln(selection);
selection := UpperCase(selection);
randomize;
if selection = 'F' then
begin
Hero.Health := Hero.Health - random(opponent.Power +1);
opponent.Health := opponent.Health - random(Hero.Power + 1);
end
else if (selection = 'M') and (Hero.Magic >0) then
begin
opponent.Health := opponent.Health - 10;
Hero.Magic := Hero.Magic - 1;
if opponenet.Health > 0 then Hero.Health := Hero.Health - random(Opponent.Power + 1);
end;
until (Selecction = 'F') of (Selection = 'M');
end;
procedure Battle;
begin
GetEnemy;
repeat
clrscr();
WriteStats;
Menu;
until (Hero.Health <= 0) of (Opponent.Health <= 0);
if Opponent.Health <= 0 then
begin
writeln(Opponent.name, ' Was Killed');
score := score + Opponent.Power;
sleep(2000);
end;
end;
begin
repeat
LoadSettings;
repeat
Battle;
until Hero.Health <=0;
clrscr();
writeln(Hero.Name , ' Wai Killed');
writeln('Final Score: ', score);
repeat
write('Play Again Y/N: ');
readln(selection);
selection := UpperCase(selection);
until (selection = 'Y') or (selection = 'N');
until selection = 'N';
end.

posted by:nikaoto(11 years old)

Report
Re: pascal can't find CTR.Tpu Posted by quikcarl on 23 Feb 2011 at 2:18 PM
It's always in the details and the details have to be right or it just won't work.

: uses
: ctr, sysutlis,
: cthreads,
: classes

Try this to get it going again.
 uses
   crt, sysutils,
   cthreads,
   classes;

Report
Re: pascal can't find CTR.Tpu Posted by nikaoto on 24 Feb 2011 at 3:17 AM
thank you for helping.i was trying to find the mistakes for weeks and you found it just in 10 minutes.


thx for all!!!
:)
Report
Re: pascal can't find CTR.Tpu Posted by nikaoto on 25 Feb 2011 at 3:58 AM
i tried to correct it but it wrote that it needed an identifier(this means that you couldn't solve the problem[SORRY])
Report
Re: pascal can't find CTR.Tpu Posted by _Atex_ on 1 Mar 2011 at 9:06 PM
: i tried to correct it but it wrote that it needed an identifier(this
: means that you couldn't solve the problem[SORRY])
:
There were quite a few errors, mostly spelling ones, did you copy this from somewhere ? Anyway here's your code patched up:
program RPG;
uses
crt;


type
 creature = record
             Name:string;
             Armor,Health,Magic,Power:integer;
           end;
 var Hero, Dragon, Spider, LargeSpider, Opponent:creature;
     enemNum:integer;
     selection:string;
     score:integer;

procedure LoadSettings;
begin
 score := 0;
 with Hero do begin
  Name:= 'hero nika';
  Armor := 2;
  Health :=10;
  Magic := 2;
  Power := 5;
 end;
 with Dragon do begin
  Name:= 'Dragon';
  Armor := 3;
  Health := 5;
  Magic := 2;
  Power := 4;
 end;
 with Spider do begin
  Name:= 'Spider';
  Armor :=0;
  Health :=1;
  Magic :=0;
  Power :=2;
 end;
 with LargeSpider do begin
  Name:= 'LargeSpider';
  Armor :=4;
  Health :=2;
  Magic :=1;
  Power :=3
 end;
end;

procedure GetEnemy;
 begin
  randomize;
  enemNum := random(3);
  case enemnum of
   0:opponent:=dragon;
   1:opponent:=spider;
   2:opponent:=largespider;
  end;
 end;


procedure WriteStats;
 begin
  with Hero do begin
   writeln(Name, ' score = ', score);
   writeln('Health = ',Health);
   writeln('Armor = ',Armor);
   writeln('Magic = ',Magic);
   writeln('Power = ',Power);
  end;
  writeln;
  writeln;
 with opponent do begin
  writeln('Opponent ',Name);
  writeln('Health = ',Health);
  writeln('Armor = ',Armor);
  writeln('Magic = ',Magic);
  writeln('Power = ',Power);
 end;
end;

function uppercase(s:string):string;
 var i:byte;sl:byte absolute s;
 begin for i:=1 to sl do s[i]:=upcase(s[i]);uppercase:=s;end;


procedure Menu;
 begin
  repeat
   writeln;
   writeln('(F)ight');
   writeln('(M)agic');
   write('Selection: ');
   readln(selection);
   selection := UpperCase(selection);
   randomize;
   if selection = 'F' then begin
        Hero.Health := Hero.Health - random(opponent.Power +1);
        opponent.Health := opponent.Health - random(Hero.Power + 1);
   end else if (selection = 'M') and (Hero.Magic >0) then begin
        opponent.Health := opponent.Health - 10;
        Hero.Magic := Hero.Magic - 1;
        if opponent.Health > 0 then Hero.Health := Hero.Health - random(Opponent.Power + 1);
   end;
  until ((Selection = 'F') or (Selection = 'M'));
end;

procedure Battle;
begin
 GetEnemy;
 repeat
  clrscr;
  WriteStats;
  Menu;
 until ((Hero.Health <= 0) or (Opponent.Health <= 0));
 if Opponent.Health <= 0 then begin
  writeln(Opponent.name, ' Was Killed');
  score := score + Opponent.Power;
  delay(2000);
 end;
end;


begin
 repeat
  LoadSettings;
  repeat
   Battle;
  until Hero.Health <=0;
  clrscr();
  writeln(Hero.Name , ' Wai Killed');
  writeln('Final Score: ', score);
  repeat
   write('Play Again Y/N: ');
   readln(selection);
   selection := UpperCase(selection);
  until ((selection = 'Y') or (selection = 'N'));
 until selection = 'N';
end.
When you post a code don't forget to put it in between the "<>", it's on the top of the editor window...
Report
Re: pascal can't find CTR.Tpu Posted by yiga194 on 7 Mar 2011 at 5:48 AM
That helped me too.

Thanks alot.



 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.