mIRC Homepage
Posted By: AWEstun if-then-else statement - 11/05/08 05:08 PM
I don't want the if-then-else statement to execute if either or both or there are $true ('set abc $true'). Technically neither will be '$true' at the same time. I unset the variables at the end of the execution, so they are $null (not 0 or false). So the only way I could get this to work was if I checked for a negative $null:

abc= $null (was unset at the end of it's routine)
cbs = $true (is set to $true before this routine)

if (!abc = $null) || (!%cbs = $null) {
...
}

Is there a better way to do this? Should I not unset vars (causes a $null), but change them to 'set %abc 0'?
Posted By: RoCk Re: if-then-else statement - 11/05/08 05:11 PM

This would check if either variable is set with any value

if ((%abc != $null) || (%cbs != $null)) {

This would check if either variable is set with any value except $null $false or 0

if ((%abc) || (%cbs)) {

This would check if either variable is set only with $true

if ((%abc == $true) || (%cbs == $true)) {
Posted By: AWEstun Re: if-then-else statement - 11/05/08 05:19 PM
Looks like I got it to work with 'if (!(%abc == $null) || (%cbs = $null)) { ...'

Hum... well now it's not working again. ???
Posted By: RoCk Re: if-then-else statement - 11/05/08 05:23 PM
Sorry, I misread your original post. Try this.

if ((%abc != $true) && (%cbs != $true)) {

This will not execute if either variable is set to $true. With this you could either unset the variables or set them to anything except $true.

You could also try this

if ((%abc != $null) || (%cbs != $null)) {

This would trigger if either variable is set with any value at all.
Posted By: AWEstun Re: if-then-else statement - 11/05/08 05:33 PM
Thanks, that seems to have fixed it.
© mIRC Discussion Forums