This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

problem with an or statement

Old posts that have not been replied to for several years.
Locked
s
simonbell
Halfop
Posts: 68
Joined: Mon Aug 05, 2002 8:07 pm
Location: Washington, England
Contact:

problem with an or statement

Post by simonbell »

Hi

would someone be able to point out what i might be doing wrong with this little script:
if { $whoisuserhand != "*" } {
set whoisuserinfo [getuser $whoisuserhand INFO]
if { ($whoisuserinfo != "") || ($whoisuserinfo != "*") } {
set whoisinfofile [open $whoisusernick-userinfo.tmp a]
puts $whoisinfofile "Info: $whoisuserinfo"
close $whoisinfofile
}
}
the problem occurs that even if "$whoisuserinfo == *" the rest of the script is still run, even though as far as i can see it should be missing out that part of the script if $whoisuserinfo == "" or "*"

am i missing something?

thanks
Simon
e
egghead
Master
Posts: 481
Joined: Mon Oct 29, 2001 8:00 pm
Contact:

Re: problem with an or statement

Post by egghead »

simonbell wrote:Hi

would someone be able to point out what i might be doing wrong with this little script:
if { $whoisuserhand != "*" } {
set whoisuserinfo [getuser $whoisuserhand INFO]
if { ($whoisuserinfo != "") || ($whoisuserinfo != "*") } {
set whoisinfofile [open $whoisusernick-userinfo.tmp a]
puts $whoisinfofile "Info: $whoisuserinfo"
close $whoisinfofile
}
}
the problem occurs that even if "$whoisuserinfo == *" the rest of the script is still run, even though as far as i can see it should be missing out that part of the script if $whoisuserinfo == "" or "*"

am i missing something?

thanks
Simon
In words you state it like: if $whoisuserinfo == "" or "*", but in code you state it differently.

If "whoisuserinfo == *":

- what will ($whoisuserinfo != "") evaluate too? TRUE or FALSE?

- what will ($whoisuserinfo != "*") evaluate too? TRUE or FALSE?

- And what will { ($whoisuserinfo != "") || ($whoisuserinfo != "*") } evaluate too?
(Read the last statement as: if "this is true" or "that is true" then ... or read it like: if {(*!="") || (*!=*)} then ...)
s
simonbell
Halfop
Posts: 68
Joined: Mon Aug 05, 2002 8:07 pm
Location: Washington, England
Contact:

Post by simonbell »

sorry, my mistake for not being clear enough.

I want to make it so that if $whoisuserinfo returns a value which IS NOT "" (as in blank) or a * then it would execute that particular part of the script.

so in words if $whoisuserinfo returns nothing, or returns a *, i want nothing to happen, but if it contains anything else, i want the script to run.
User avatar
stdragon
Owner
Posts: 959
Joined: Sun Sep 23, 2001 8:00 pm
Contact:

Post by stdragon »

What you said is fine, all you have to do is turn it into code. The part where you mess up is you're not being detailed in what you say.

Here's what you really mean:

if $whoisuserinfo is not "", AND $whoisuserinfo is not "*", then do this
otherwise do nothing

Another way to say it, closer to what you actually said, is

if $whoisuserinfo is "" OR $whoisuserinfo is "*" then do nothing
otherwise do this

As you can see that logic is kind of backwards. But either one will work.
Locked