Not Equal to check

For builders to discuss and ask building questions.
Post Reply
User avatar
Algon
Sword Grand Master
Sword Grand Master
Posts: 1070
Joined: Thu Aug 14, 2003 12:44 am
Location: Waterdeep

Not Equal to check

Post by Algon » Wed Nov 05, 2014 3:34 pm

I am not sure if there is anything like this out there, my searching through the lessons have not found anything like it. But is there any kind of command that would allow for a check if something is not equal to something?
Example...

Code: Select all

>intercept_prog kill~
if questr(0,0,3,$n) /= 1
  do so and so
This would allow for the builder to only have to use one check instead of...

Code: Select all

>intercept_prog kill~
if questr(0,0,3,$n) == 2
or questr(0,0,3$n) ==3
or questr(0,0,3$n) ==4
etc...
Assuming that the 'or" function works with qbits, not sure. But, I digress.
This would make things so much easier when trying to check for something like checking for a specific thing.
Another example...

Code: Select all

>greet_prog 100~
if class /= wizard
mpechoat $n "Go Away! 
I know you could accomplish this same thing with the else command, but this would be a much shorter way of going about things.

As I said before, I am not sure if this would even be plausible. But, I thought I would share the idea.
Thanks!
Counting bodies like sheep...to the rhythm of the war drums. ~~~ Maynard
Xryon
Sword Master
Sword Master
Posts: 233
Joined: Thu Aug 25, 2005 5:24 am
Location: Waterdeep

Re: Not Equal to check

Post by Xryon » Wed Nov 05, 2014 4:25 pm

I'm no builder here, but I know a lot of codebases support != as 'does not equal.' Could try that out.
User avatar
Harroghty
Staff
Staff
Posts: 9695
Joined: Tue Jul 27, 2004 5:38 pm

Re: Not Equal to check

Post by Harroghty » Thu Nov 06, 2014 12:03 am

Yes, Xyron's correct in this case. You can use != or, as you said, else. In many cases it is six in one hand and a half dozen in the other.

e.g.

Code: Select all

>greet_prog 100~
if class($n) != warrior
  sayto $n This guild is only for warriors!
else
  sayto $n Hi
endif
~
or

Code: Select all

>greet_prog 100~
if class($n) == warrior
  sayto $n Hi
else
  sayto $n This guild is only for warriors!
endif
~
"A man may die yet still endure if his work enters the greater work, for time is carried upon a current of forgotten deeds, and events of great moment are but the culmination of a single carefully placed thought." - Chime of Eons
User avatar
Algon
Sword Grand Master
Sword Grand Master
Posts: 1070
Joined: Thu Aug 14, 2003 12:44 am
Location: Waterdeep

Re: Not Equal to check

Post by Algon » Thu Nov 06, 2014 12:48 am

Perfect! That is exactly what I was needing. Thank you both!
Counting bodies like sheep...to the rhythm of the war drums. ~~~ Maynard
Post Reply