comp.lang.ada
 help / color / mirror / Atom feed
From: Stephen Leake <stephen.a.leake.1@gsfc.nasa.gov>
Subject: Re: Need help for a Calculator program
Date: 04 Feb 2002 08:54:09 -0500
Date: 2002-02-04T13:58:45+00:00	[thread overview]
Message-ID: <upu3lwdxa.fsf@gsfc.nasa.gov> (raw)
In-Reply-To: a3jlnb$s9l$1@paris.btinternet.com

"Jim" <genx54321@hotmail.com> writes:

> ive now used "end_of_line" instead of "if operator = '.' then put(result)".
> 
> but what happens now, you can put any character after the expression eg 1 +
> 2 + 3f,  1 + 2 + 3z press enter and get the answer.
> 
> if you dont put anything after the last operand it doesnt do anything.  This
> is because the loop has the check the next character after the last operand
> right ?
> 
> how do i make loop exit without it actually reading the next character ?

Well, I need to see the code to be sure. 

I would read an entire line into a string, using Get_Line (Buffer,
Buffer_Last). Then go thru the string looking for operators and
operands. When you get to the end of the string, you are done.

Or you can require the user to enter a semicolon to terminate a
statement, like Ada does. That makes things simpler for the
programmer, which is ok while you are just learning.

-- 
-- Stephe



  reply	other threads:[~2002-02-04 13:54 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-02-01 12:06 Need help for a Calculator program Jim
2002-02-01 12:41 ` John English
2002-02-01 14:07 ` Preben Randhol
2002-02-01 18:17 ` Stephen Leake
2002-02-01 18:57   ` Jim
2002-02-01 23:20   ` Jeffrey Carter
2002-02-01 23:46 ` Jim
2002-02-02  4:12   ` Eric Merritt
2002-02-02 16:22     ` Jim
2002-02-02 12:04   ` Preben Randhol
2002-02-03 15:41 ` Jim
2002-02-04 13:54   ` Stephen Leake [this message]
2002-02-12 11:55     ` John English
2002-02-12 15:43       ` Pat Rogers
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox