LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 10-20-2004, 10:48 PM   #1
flamesrock
Member
 
Registered: Aug 2003
Distribution: Gentoo 2006.1
Posts: 405

Rep: Reputation: 30
Pascal App Wont Compile (newb, help!)


Ok, so I'm sorry if this is a silly question, but I've checked the code over and over again, and I simply can't figure out why it wont compile.

Here's the error:
Quote:
assignment4Equation_Solver.p: In procedure `Temptotal':
assignment4Equation_Solver.p:4: invalid use of void expression
assignment4Equation_Solver.p:5: invalid use of void expression
assignment4Equation_Solver.p: In procedure `Parsenum':
assignment4Equation_Solver.p:8: parse error before `Read'
And here is the code:

Code:
Program assignment4Equation_Solver(input,output);
Procedure tempTotal(var total, numtemptotal);
  begin
  numtempTotal := total; {store the total remotely}
  total := 0;            {reset the total}
  end;
Procedure parseNum(var total);  
  read(ch);
  while (ch in [0,9]) then
  total := total*10+(ord(ch)- ord('10'));
  until (not ch in['0','9'])
    if (ch = '.') then
    {read another integer}
    {combine the +ve numbers}
      begin
      read(ch);
      while (ch in [0,9]) then
      total := total+(ord(ch) / ord('10'));
      until (not ch in['0','9'])
      end;
Procedure chkNextInput; {checks to see if next input is a number, and not another operator}
if (not ch in [0,9]) then
begin
writeln('Bad Input')
badInput := true;
Break;
end;

CONST

VAR
  total,
  numtempTotal: real;
  badInput: boolean;

begin
{*
input
*}
  badInput := false;
  write('Enter the Equation: ');
  readln(equation);
{*
Parse the input, check for errors and calculate total.
*}

numtempTotal := 0;
total := 0;
while not eoln(equation) do
begin
if (badInput) then
  begin
  Break;
  end;
readNum;
read(ch);
case ch of 
'+';
tempTotal(total);
parseNum;
total := total + numtempTotal;
chkNextInput;

case ch of 
'-'
tempTotal(total);
parseNum;
total := total - numtempTotal;
chkNextInput;

case ch of 
'*'
tempTotal(total);
parseNum;
total := total * numtempTotal;
chkNextInput;

case ch of 
'/'
tempTotal(total);
parseNum;
total := total / numtempTotal;
chkNextInput;

if (eoln(equation)) then
  writeln('The answer to the equation is: ', total);
else
  if (badInput) then
  begin
  Break;
  end;
end;
  
end.
I'm a complete newb to pascal, but it looks fine to me..

-thanks in advance

Last edited by flamesrock; 10-20-2004 at 10:51 PM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
intel PRO/Wireless 2200 still wont work!!! NEWB danimal87 Linux - Hardware 3 02-27-2005 01:12 AM
Can't compile QT App. Wolverine Programming 26 10-06-2004 10:54 AM
KDE borderless app, that ALT F3 wont fix meshsmooth Linux - General 0 07-15-2004 07:24 PM
Looking for help on how to compile app for cron bgriesi Linux - Software 0 06-25-2004 10:46 PM
Trouble with newb kernel compile vortical Linux - General 5 03-02-2004 10:23 AM


All times are GMT -5. The time now is 06:34 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration