Re: Another Error

new topic     » goto parent     » topic index » view thread      » older message » newer message

Rich Klender wrote:

> 
> Well, I hit another snag, if anyone would be gracious enough to help!!!
> 
> Here's the code:
> 
> function AddFactions(integer C)
> 
>     sequence FactionName, FactionPassword, Correct
>     integer ReturnCode
> 
>     while C do
> 
>         FactionName = prompt_string("Input the name of the new Faction\n")
>         
>         FactionPassword = prompt_string("Input the Factions password\n")
> 
>         puts(1, "\n")
>         puts(1, "The Faction name is: ")
>         puts(1, FactionName)
>         puts(1, "\nThe Password is: ")
>         puts(1, FactionPassword)
>         puts(1, "\n")
>         Correct = prompt_string("Is this correct? y/n")
> 
>         if Correct = 'y' or Correct = 'Y' then
>             return ReturnCode = 1   
>         end if
> 
>     end while
> 
> end function
> 
> The problem is in the last if/then statement, if the user inputs 'y' then it
> returns to the main program, if not I want it to fall thru and the user
> re-inputs
> the correct data.  I get the following error:
> 
> H:\test1.ex:24 in function AddFactions() 
> true/false condition must be an ATOM 
>     C = 1
>     FactionName = "asdf"
>     FactionPassword = "asdf"
>     Correct = "n"
>     ReturnCode = <no value>
> 
> ... called from H:\test1.ex:62 
> 
> I know I'm missing something easy here...sorry I'll get the hang of this yet!!
> 
> Thanks!
> Rich

Hi Rich,

Yes, that *error message* itself is not as clear
as it could be:

"true/false condition must be an ATOM"

What is it ?

Your real mistake is just *comparing* an ATOM aginst a
SEQUENCE with the '=' operator, which acts for atoms only.
The 'Correct' variable is a sequence, 'y' and 'Y' are the
atoms, but for objects (atoms & sequences) we have two
special functions - compare() and equal(), not the '=' operator.

Read please once more that *error message*, it seems to me that
thing about comparing is just clear, but the message about
mistake is something cryptic and requires to be changed or
better explained in docs, at least.

The EU docs haven't a full list of the error and warning
messages of interpreter, binder and translator with their
explanations. It may be just one of the future steps in
development of Euphoria.

Just my $0.02.

Regards,
Igor Kachan
kinz at peterlink.ru

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu