* whats semicolon?
@ 2003-10-23 20:47 @{-_-}@
2003-10-23 21:33 ` Simon Wright
` (3 more replies)
0 siblings, 4 replies; 11+ messages in thread
From: @{-_-}@ @ 2003-10-23 20:47 UTC (permalink / raw)
Im triying to develop a code in ADA. Im a newbie :). This code must
ouput a series number.
If I try a number N lagger than nought the program must ouput a
progressive series number from 1 as far as N.
If I try a number N smaller than nought, the program must output a
progressive series number from -1 as far as N.
If I try nouth the program must output "ZERO".
I tried the following intructions:
with Text_Io, Ada.Integer_Text_IO;
use Text_Io, Ada.Integer_Text_IO;
procedure Practica1 is
n: integer;
c: integer :=0;
begin
put ("Escribe un numero entero: ");
get (n);
if n = 0 then
put("cero")
else
IF N > 0 then
for c in 0..n loop
put (c);
end loop
else
for c in -1..n loop
put (c);
end loop
end if
end if
end Practica1;
When I try to compile it, the objectada show the following error:
practica1.adb: Error: line 20 col 2 Parse error: expected SEMICOLON, got
ELSE, Inserting SEMICOLON
Whats SEMICOLON?
Thx to community!!
gretting2all!!!
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: whats semicolon?
2003-10-23 20:47 whats semicolon? @{-_-}@
@ 2003-10-23 21:33 ` Simon Wright
2003-10-23 23:32 ` Ludovic Brenta
` (2 subsequent siblings)
3 siblings, 0 replies; 11+ messages in thread
From: Simon Wright @ 2003-10-23 21:33 UTC (permalink / raw)
"@{-_-}@" <nuhvok@terra.es> writes:
> Im triying to develop a code in ADA. Im a newbie :). This code must
> ouput a series number.
>
> If I try a number N lagger than nought the program must ouput a
> progressive series number from 1 as far as N.
>
> If I try a number N smaller than nought, the program must output a
> progressive series number from -1 as far as N.
>
> If I try nouth the program must output "ZERO".
>
> I tried the following intructions:
>
> with Text_Io, Ada.Integer_Text_IO;
> use Text_Io, Ada.Integer_Text_IO;
>
> procedure Practica1 is
>
> n: integer;
> c: integer :=0;
>
> begin
>
> put ("Escribe un numero entero: ");
> get (n);
> if n = 0 then
>
> put("cero")
>
> else
>
> IF N > 0 then
> for c in 0..n loop
> put (c);
> end loop
> else
> for c in -1..n loop
> put (c);
> end loop
> end if
>
> end if
>
> end Practica1;
>
> When I try to compile it, the objectada show the following error:
>
> practica1.adb: Error: line 20 col 2 Parse error: expected SEMICOLON,
> got ELSE, Inserting SEMICOLON
>
> Whats SEMICOLON?
;
In Ada, the semicolon is a terminator not a separator.
if n = 0 then
put ("cero");
else
(can you see that this fails to meet your requirements as stated in at
least two respects?)
Same semicolon problem later on at end loop; end if; .
--
Simon Wright 100% Ada, no bugs.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: whats semicolon?
2003-10-23 20:47 whats semicolon? @{-_-}@
2003-10-23 21:33 ` Simon Wright
@ 2003-10-23 23:32 ` Ludovic Brenta
2003-10-23 23:56 ` Martin Dowie
` (2 more replies)
[not found] ` <n2mm61-fg3.ln1@beastie.ix.netcom.com>
2003-10-25 13:39 ` Roberto Waltman
3 siblings, 3 replies; 11+ messages in thread
From: Ludovic Brenta @ 2003-10-23 23:32 UTC (permalink / raw)
"@{-_-}@" <nuhvok@terra.es> writes:
> with Text_Io, Ada.Integer_Text_IO;
> use Text_Io, Ada.Integer_Text_IO;
^^^^^^^
This package is obsolete. It is recommended to use Ada.Text_IO
instead. But this will not harm your program until the next revision
of Ada.
> procedure Practica1 is
>
> n: integer;
> c: integer :=0;
^^^^^^^^^^^^^^^^
You do not need to declare this variable. The "for" loops below will
declare it implicitly for you.
> begin
> put ("Escribe un numero entero: ");
> get (n);
> if n = 0 then
> put("cero")
> else
> IF N > 0 then
> for c in 0..n loop
> put (c);
> end loop
> else
> for c in -1..n loop
^^^^^^^^
This loop will be executed zero or one times, depending on n. Do you
understand why? Is this whant you want?
> put (c);
> end loop
> end if
> end if
> end Practica1;
Regarding the semicolons, Simon Wright answered already. It looks
like you come from Pascal :)
HTH
--
Ludovic Brenta.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: whats semicolon?
2003-10-23 23:32 ` Ludovic Brenta
@ 2003-10-23 23:56 ` Martin Dowie
2003-10-24 1:19 ` Jeffrey Carter
2003-10-24 13:28 ` Preben Randhol
2 siblings, 0 replies; 11+ messages in thread
From: Martin Dowie @ 2003-10-23 23:56 UTC (permalink / raw)
"Ludovic Brenta" <ludovic.brenta@insalien.org> wrote in message
news:m3u15z4jjl.fsf@insalien.org...
> "@{-_-}@" <nuhvok@terra.es> writes:
>
> > with Text_Io, Ada.Integer_Text_IO;
> > use Text_Io, Ada.Integer_Text_IO;
> ^^^^^^^
>
> This package is obsolete. It is recommended to use Ada.Text_IO
> instead. But this will not harm your program until the next revision
> of Ada.
No - they will still be there, but they will still be obsolete! :-)
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: whats semicolon?
2003-10-23 23:32 ` Ludovic Brenta
2003-10-23 23:56 ` Martin Dowie
@ 2003-10-24 1:19 ` Jeffrey Carter
2003-10-24 13:28 ` Preben Randhol
2 siblings, 0 replies; 11+ messages in thread
From: Jeffrey Carter @ 2003-10-24 1:19 UTC (permalink / raw)
Ludovic Brenta wrote:
> "@{-_-}@" <nuhvok@terra.es> writes:
>
>>c: integer :=0;
>
> ^^^^^^^^^^^^^^^^
>
> You do not need to declare this variable. The "for" loops below will
> declare it implicitly for you.
Technically, this variable is never used.
To answer the OP's question, a semicolon is the character ';'. Every
statement in Ada must be terminated by a semicolon.
--
Jeff Carter
"C++ is like jamming a helicopter inside a Miata
and expecting some sort of improvement."
Drew Olbrich
51
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: whats semicolon?
2003-10-23 23:32 ` Ludovic Brenta
2003-10-23 23:56 ` Martin Dowie
2003-10-24 1:19 ` Jeffrey Carter
@ 2003-10-24 13:28 ` Preben Randhol
2003-10-24 14:34 ` Martin Dowie
2 siblings, 1 reply; 11+ messages in thread
From: Preben Randhol @ 2003-10-24 13:28 UTC (permalink / raw)
On 2003-10-23, Ludovic Brenta <ludovic.brenta@insalien.org> wrote:
> "@{-_-}@" <nuhvok@terra.es> writes:
>
>> with Text_Io, Ada.Integer_Text_IO;
>> use Text_Io, Ada.Integer_Text_IO;
> ^^^^^^^
>
> This package is obsolete. It is recommended to use Ada.Text_IO
> instead. But this will not harm your program until the next revision
> of Ada.
I hadn't even noticed that there is a text_io package other than
Ada.Text_IO. However, in Gnat it is the same package as text_io.ads
contains only:
[copyright removed]
pragma Ada_95;
with Ada.Text_IO;
package Text_IO renames Ada.Text_IO;
Preben
--
"Saving keystrokes is the job of the text editor, not the programming
language."
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: whats semicolon?
2003-10-24 13:28 ` Preben Randhol
@ 2003-10-24 14:34 ` Martin Dowie
2003-10-24 15:10 ` Preben Randhol
0 siblings, 1 reply; 11+ messages in thread
From: Martin Dowie @ 2003-10-24 14:34 UTC (permalink / raw)
"Preben Randhol" <randhol+valid_for_reply_from_news@pvv.org> wrote in
message
> with Ada.Text_IO;
>
> package Text_IO renames Ada.Text_IO;
Because that's what the RM says is should...
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: whats semicolon?
2003-10-24 14:34 ` Martin Dowie
@ 2003-10-24 15:10 ` Preben Randhol
2003-10-24 17:20 ` Martin Dowie
0 siblings, 1 reply; 11+ messages in thread
From: Preben Randhol @ 2003-10-24 15:10 UTC (permalink / raw)
On 2003-10-24, Martin Dowie <martin.dowie@btopenworld.com> wrote:
> "Preben Randhol" <randhol+valid_for_reply_from_news@pvv.org> wrote in
> message
>
>> with Ada.Text_IO;
>>
>> package Text_IO renames Ada.Text_IO;
>
> Because that's what the RM says is should...
hmm, but then I don't understand why Text_IO is obsolete. Is it because
it is not under Ada. ?
Preben
--
"Saving keystrokes is the job of the text editor, not the programming
language."
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: whats semicolon?
2003-10-24 15:10 ` Preben Randhol
@ 2003-10-24 17:20 ` Martin Dowie
0 siblings, 0 replies; 11+ messages in thread
From: Martin Dowie @ 2003-10-24 17:20 UTC (permalink / raw)
"Preben Randhol" <randhol+valid_for_reply_from_news@pvv.org> wrote in
message
news:slrnbpig6o.rlc.randhol+valid_for_reply_from_news@kiuk0156.chembio.ntnu.no...
> On 2003-10-24, Martin Dowie <martin.dowie@btopenworld.com> wrote:
> > "Preben Randhol" <randhol+valid_for_reply_from_news@pvv.org> wrote in
> > message
> >
> >> with Ada.Text_IO;
> >>
> >> package Text_IO renames Ada.Text_IO;
> >
> > Because that's what the RM says is should...
>
> hmm, but then I don't understand why Text_IO is obsolete. Is it because
> it is not under Ada. ?
It's obsolete as you should be using the Ada.* hierarchy in new code, but
they
couldn't remove 'Text_IO' as this would break *huge* amounts of existing
code.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: whats semicolon?
[not found] ` <n2mm61-fg3.ln1@beastie.ix.netcom.com>
@ 2003-10-24 20:06 ` Simon Wright
0 siblings, 0 replies; 11+ messages in thread
From: Simon Wright @ 2003-10-24 20:06 UTC (permalink / raw)
Dennis Lee Bieber <wlfraed@ix.netcom.com> writes:
> put("Zero");
^^^
Still doesn't match the spec!
--
Simon Wright 100% Ada, no bugs.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: whats semicolon?
2003-10-23 20:47 whats semicolon? @{-_-}@
` (2 preceding siblings ...)
[not found] ` <n2mm61-fg3.ln1@beastie.ix.netcom.com>
@ 2003-10-25 13:39 ` Roberto Waltman
3 siblings, 0 replies; 11+ messages in thread
From: Roberto Waltman @ 2003-10-25 13:39 UTC (permalink / raw)
>Im triying to develop a code in ADA. Im a newbie :). This code must
>ouput a series number.
>
> <snip>...
>
>When I try to compile it, the objectada show the following error:
>
>practica1.adb: Error: line 20 col 2 Parse error: expected SEMICOLON, got
>ELSE, Inserting SEMICOLON
>
>Whats SEMICOLON?
Colon - Dos puntos - ':'
Semicolon - Punto y coma - ';'
R.W
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2003-10-25 13:39 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-10-23 20:47 whats semicolon? @{-_-}@
2003-10-23 21:33 ` Simon Wright
2003-10-23 23:32 ` Ludovic Brenta
2003-10-23 23:56 ` Martin Dowie
2003-10-24 1:19 ` Jeffrey Carter
2003-10-24 13:28 ` Preben Randhol
2003-10-24 14:34 ` Martin Dowie
2003-10-24 15:10 ` Preben Randhol
2003-10-24 17:20 ` Martin Dowie
[not found] ` <n2mm61-fg3.ln1@beastie.ix.netcom.com>
2003-10-24 20:06 ` Simon Wright
2003-10-25 13:39 ` Roberto Waltman
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox