Solved

Compiler Difficulties

Posted on 1997-09-24
7
209 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
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
Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

 
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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

This article describes my battle tested process for setting up delegation. I use this process anywhere that I need to setup delegation. In the article I will show how it applies to Active Directory
Learn how to PXE Boot both BIOS & UEFI machines with DHCP Policies and Custom Vendor Classes
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

830 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