Solved

Compiler Difficulties

Posted on 1997-09-24
7
210 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
On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

 
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 20 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Delphi XE, DataSnap, JSon and java 8 1,122
Lazarus (freePascal) DB Project Assistance 14 497
.dat problems 39 215
Regular Expression to Split a String 7 157
Had a business requirement to store the mobile number in an environmental variable. This is just a quick article on how this was done.
How many times a day do you open, acknowledge, or close an IT incident? What’s your process? Do you have a process depending on the incident, systems involved, and other factors? New Relic Alerts gives you options for how you interact with notifica…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…
Suggested Courses

752 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