Recent

Author Topic: Error in Compiling and run a program  (Read 4830 times)

Pernicles

  • Newbie
  • Posts: 4
Error in Compiling and run a program
« on: October 08, 2015, 01:05:16 am »
Hi, i'm new in Pascal and new with Lazarus.
I have a iMac with El Capitan installed and Lazarus 1.4.2
I made the installation of the three programs to install Lazarus.
The installation is correct, i think. I put the Xcode 4.6.3 and i copy the gdb to a directory for the installation of Lazarus.
Now i made a simple program in Pascal:

program Coroa_Circular;

        var r1,r2,p1,p2,area: real;


begin
         write('Raio Interior:');
         readln(r1);


         write('Raio Exterior:');
         readln(r2);

         area:= PI*(sqr(r2)-sqr(r2));

         p1:= 2*PI*(r1);

         p2:=2*PI*(r2);

         write('Area= ', area);
         write('Perimetro Interior= ',p1);
         Write('Perimetro Exterior= ',p2);

end.   

Then i run the program and the compiler don't Work.
He say: Compile Project, Target: Coroa_circular: Exit code 1, Errors 1
Fatal: Compilation aborted.

Can anyone help me?
Thanks!

BobS

  • Full Member
  • ***
  • Posts: 153
Re: Error in Compiling and run a program
« Reply #1 on: October 08, 2015, 03:33:51 am »
Before you compile it look at the area:= statement.  Tell me why you have sqr(r2)-sqr(r2) in there...what is any number - itself?

Your code does compile if you use lazarus to create a new console application and insert your code where it tells you too (put your var statement up with the other var in that procedure and remove your begin and end. statements as they are provided for you in the template.

BobS

  • Full Member
  • ***
  • Posts: 153
Re: Error in Compiling and run a program
« Reply #2 on: October 08, 2015, 03:52:35 am »
Oh and the way your program is now PI is undefined.  You need to include mathh or just define it yourself and assign a value to it (or create it as a constant);
e.g.
var
  Pi:real

then initialize in your program with something like:
  Pi:=3.141592654;

or simply use a constant:
const
  Pi=3.141592654

Leledumbo

  • Hero Member
  • *****
  • Posts: 8757
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: Error in Compiling and run a program
« Reply #3 on: October 08, 2015, 05:13:19 am »
Oh and the way your program is now PI is undefined.  You need to include mathh or just define it yourself and assign a value to it (or create it as a constant);
No need, Pi is defined in the system unit, not math.

BobS

  • Full Member
  • ***
  • Posts: 153
Re: Error in Compiling and run a program
« Reply #4 on: October 08, 2015, 05:25:28 am »
Help files in Lazarus state it's in mathh as in "Source position: mathh.inc line 69."  Should have made sure though before confusing a beginner.

BobS

  • Full Member
  • ***
  • Posts: 153
Re: Error in Compiling and run a program
« Reply #5 on: October 08, 2015, 05:52:17 am »
Edit: ignore this!

Oh and the way your program is now PI is undefined.  You need to include mathh or just define it yourself and assign a value to it (or create it as a constant);
e.g.
var
  Pi:real

then initialize in your program with something like:
  Pi:=3.141592654;

or simply use a constant:
const
  Pi=3.141592654

Leledumbo

  • Hero Member
  • *****
  • Posts: 8757
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: Error in Compiling and run a program
« Reply #6 on: October 08, 2015, 08:25:15 am »
Help files in Lazarus state it's in mathh as in "Source position: mathh.inc line 69."  Should have made sure though before confusing a beginner.
Yep, that file is included by systemh.inc which in turn is included by system.pp of each supported OS ;)

BobS

  • Full Member
  • ***
  • Posts: 153
Re: Error in Compiling and run a program
« Reply #7 on: October 08, 2015, 09:46:03 am »
And the really dumb thing was I did a quick compile on the code to make sure I wasn't missing something, so I already knew it didn't need mathh ...where is the head banging emoticon when you need it.

Pernicles

  • Newbie
  • Posts: 4
Re: Error in Compiling and run a program
« Reply #8 on: October 09, 2015, 12:56:51 am »
Hi, again.
Why can not see the results of the program in a window ? it disappears.

Thanks
« Last Edit: October 09, 2015, 09:31:42 pm by Pernicles »

BobS

  • Full Member
  • ***
  • Posts: 153
Re: Error in Compiling and run a program
« Reply #9 on: October 09, 2015, 10:05:57 pm »
I'm not that familiar with Mac, but in Windows this can happen because of scaling/dpi.  If you look in the Window menu of Lazarus it has a 'center lost window' choice, see if your window is listed there.

BobS

  • Full Member
  • ***
  • Posts: 153
Re: Error in Compiling and run a program
« Reply #10 on: October 09, 2015, 10:15:11 pm »
Or if you mean it shows up for the input and then disappears because it's a console program then at the end of the program write a message like "Press Enter when done." and do a final readln.

 

TinyPortal © 2005-2018