For Programmers: Free Programming Magazines  


Home > Archive > Fortran > March 2004 > Beginner problem









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Beginner problem
Oodini

2004-03-27, 12:18 am

Hello,

I've got troubles with this piece of code, compiled with ABsoft.

---------------------------------------------------------
IMPLICIT CHARACTER (C)

WRITE (*,"(A)", ADVANCE="NO") " Type a letter> "
READ *, CLETTRE

CLETTRE = TO_UPPER (CLETTRE)

SELECT CASE (CLETTRE)
CASE (:'A'); CLETTRE = 'A'
CASE (:'Z'); CLETTRE = 'Z'
END SELECT
---------------------------------------------------------

The line 17 is the first CASE (A), and the line 18 the second CASE (Z).

The problem occurs at the line 18:
"The case-value range overlaps a case-value range on line 17"

Thanks for help.

Jugoslav Dujic

2004-03-27, 12:18 am

Oodini wrote:
| Hello,
|
| I've got troubles with this piece of code, compiled with ABsoft.
|
| ---------------------------------------------------------
| IMPLICIT CHARACTER (C)
|
| WRITE (*,"(A)", ADVANCE="NO") " Type a letter> "
| READ *, CLETTRE
|
| CLETTRE = TO_UPPER (CLETTRE)
|
| SELECT CASE (CLETTRE)
| CASE (:'A'); CLETTRE = 'A'
| CASE (:'Z'); CLETTRE = 'Z'
| END SELECT
| ---------------------------------------------------------
|
| The line 17 is the first CASE (A), and the line 18 the second CASE (Z).
|
| The problem occurs at the line 18:
| "The case-value range overlaps a case-value range on line 17"

CASE(:'A') means: "every letter from char(0) to char(ichar('A'))";
similarly, CASE(:'Z') "every letter from char(0) to char(ichar('Z'))".

That means that ranges indeed overlap, having char(0) --
char(ichar('A')-1) = '@' in intersection.

But what are you actually *trying* to achieve? It's not clear
from your post.

--
Jugoslav
___________
www.geocities.com/jdujic

Please reply to the newsgroup.
You can find my real e-mail on my home page above.

Oodini

2004-03-27, 12:18 am

Jugoslav Dujic a écrit:


> CASE(:'A') means: "every letter from char(0) to char(ichar('A'))";
> similarly, CASE(:'Z') "every letter from char(0) to char(ichar('Z'))".
>
> That means that ranges indeed overlap, having char(0) --
> char(ichar('A')-1) = '@' in intersection.
>
> But what are you actually *trying* to achieve? It's not clear
> from your post.


Well, I tried to copy a code from a book, and I mistyped CASE(:'Z').
I was supposed to type CASE('Z':)
These ":" stuff are explained later in the book...

Thanks for your help !

Jugoslav Dujic

2004-03-27, 12:18 am

Oodini wrote:
| Jugoslav Dujic a écrit:
|
|
|| CASE(:'A') means: "every letter from char(0) to char(ichar('A'))";
|| similarly, CASE(:'Z') "every letter from char(0) to char(ichar('Z'))".
||
|| That means that ranges indeed overlap, having char(0) --
|| char(ichar('A')-1) = '@' in intersection.
||
|| But what are you actually *trying* to achieve? It's not clear
|| from your post.
|
| Well, I tried to copy a code from a book, and I mistyped CASE(:'Z').
| I was supposed to type CASE('Z':)

I bet you copied & pasted previous line? It's THE most frequent
source of errors :-) (also known as "copypasto").

--
Jugoslav
___________
www.geocities.com/jdujic

Please reply to the newsgroup.
You can find my real e-mail on my home page above.

Oodini

2004-03-27, 12:18 am

Jugoslav Dujic a écrit:

> | Well, I tried to copy a code from a book, and I mistyped CASE(:'Z').
> | I was supposed to type CASE('Z':)
>
> I bet you copied & pasted previous line? It's THE most frequent
> source of errors :-) (also known as "copypasto").


No, you're wrong. Copies from a book is by far more dangerous. :-)

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2009 codecomments.com