Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Compiler Difficulties

Posted on 1997-09-24
7
Medium Priority
?
213 Views
Last Modified: 2010-04-16
I'm using Borland Turbo Pascal ver. 6.0 and it seems that the book I'm using to program with (I'm a beginner) is not compatible with the program.  I have copied programs word for word out of the book and, when I try to run or compile, the TP interpretter gives me an error message saying "Begin needed", when in fact the program is perfect according to the book.  I've tried this numerous times and either my programming style or the compiler/interpretter are seriously hindering the completion and application of my programs.  What can I do to fix this?  

Here is one of programs I copied word-for-word out of the book I'm using for those of you who enquired:

program Sine; (Input, Output);

   const
      Pi = 3.14159
      MinAngle = 0
      MaxAngle = 360

   var
      Theta, X : Real
      Work : Char

begin
   WriteLn ('Hello.');
      begin
         X := 180
         Theta = Sin(X)
      end
   WriteLn (Theta);
end.
0
Comment
Question by:Krueger092397
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 

Expert Comment

by:ptiemann
ID: 1215919
Probably the book is very bad and has errors.
You may post such a sample program here and we can tell
you whether the book is wrong or not.
0
 

Expert Comment

by:berox
ID: 1215920
Are you sure you have copied complete programs out of the book,
And not just some fragments ?
As ptiemann said before , You have to post an example to see what is exactly wrong...
0
 

Author Comment

by:Krueger092397
ID: 1215921
Edited text of question
0
[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

 
LVL 1

Expert Comment

by:potsy
ID: 1215922
what is this part of the program used for? (Input, Output) are you trying to link to it from another program? it also helps if you end your lines with ;
0
 
LVL 1

Accepted Solution

by:
FuzzyLogic earned 60 total points
ID: 1215923
If I understand properly your question, the source you included it taken from your book...

Well, in THIS program, there are two errors:
  - After the program name (Sine) and the IO, there sould not be
    a semicolon. The first line should be something like:
       program Sine(input,output);
    Anyway, I think that in TP 6.0 you don't need the IO, and
       program Sine;
    would be enough.
    This is the place where the compiler says "BEGIN excepted".

  - After any statement, includnig the CONST part, you sould put
    semicolon:
       Pi = 3.141592;
    and so on in the VAR and in the program itself.

One more thing about this program: there is a logical-block with no need - between the two WRITELN.

Now ,to your question: What should you do...
That easy. You should do two things:
1. Get yourself a GOOD book that has programs WITHOUT bugs...
2. Get yourself a newer version of TP.
0
 

Expert Comment

by:igork
ID: 1215924
The answer is good, but the program is bad amazingly for the textbook. There is also a bug related to Pascal assignement operator. One should always use ":=" instead "=" if he wants to assign value to variable. The "=" operator is boolean comparison or constant definition.
So line THETA=SIN(X) should be also rewritten as THETA:=SIN(X).

And of course you should get Borland Pascal 7.0.

Regards,
IgorK.
0
 

Author Comment

by:Krueger092397
ID: 1215925
Well, thanks a lot, folks.
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Check out what's been happening in the Experts Exchange community.
The main intent of this article is to make you aware of ‘Exchange fail to mount’ error, its effects, causes, and solution.
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Suggested Courses

664 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question