Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to "verify" your details, making threats, or asking for money, are
spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the
password reset link.
Entire forum
➜ MUSHclient
➜ General
➜ if statement help.
It is now over 60 days since the last post. This thread is closed.
Refresh page
Posted by
| David Berthiaume
(202 posts) Bio
|
Date
| Sun 19 Feb 2006 09:22 AM (UTC) Amended on Sun 19 Feb 2006 09:23 AM (UTC) by David Berthiaume
|
Message
| Right then I know how to use if and elseif, been using them for years now.
The question is can I do a general if statement(pseudo-code to follow)?stuff = "%1"
if stuff = (numbers but no characters... I.E. words or letters) then
(do stuff here)
elseif stuff = "ON" then
(do more stuff)
elseif stuff = "OFF" then
(more stuff)
else
(something else)
end if
Basically, I want to be able find out if the wildcard is numeral digits, and not letters. | Top |
|
Posted by
| David Haley
USA (3,881 posts) Bio
|
Date
| Reply #1 on Sun 19 Feb 2006 09:43 AM (UTC) |
Message
| You'll have to call some function on the wildcard, that will return true or false accordingly. Such functions typically have names like "is_number", "IsNumber", "IsNumeric", etc. |
David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone
http://david.the-haleys.org | Top |
|
Posted by
| David Berthiaume
(202 posts) Bio
|
Date
| Reply #2 on Mon 20 Feb 2006 12:48 AM (UTC) |
Message
| In the immortal words of the Guiness guys... Brilliant! | Top |
|
Posted by
| Thalir
(13 posts) Bio
|
Date
| Reply #3 on Sun 05 Aug 2007 01:40 AM (UTC) |
Message
| I have a tiny question, so I'll reply to this post instead of a making a new thread.
How do I make an:
IF a == b then
(do nothing) -- Is it possible to (do nothing)?
elseif b == c then
Note ("Aha!")
end | Top |
|
Posted by
| Shaun Biggs
USA (644 posts) Bio
|
Date
| Reply #4 on Sun 05 Aug 2007 01:49 AM (UTC) |
Message
| why not just test for if ( a != b ) and ( b == c ) to get it all in one statement? Some languages will allow you to have empty thens, but it it much more sane looking to just for what you're looking for than to test for what you're not looking for and using an else. The unequals is also varies a lot in different languages. The most popular seem to be != and <>, with Lua using ~=. If an unequals doesn't exist, then you can usually just negate the test with something like not( a == b ) |
It is much easier to fight for one's ideals than to live up to them. | Top |
|
Posted by
| Worstje
Netherlands (899 posts) Bio
|
Date
| Reply #5 on Sun 05 Aug 2007 01:55 AM (UTC) Amended on Sun 05 Aug 2007 01:58 AM (UTC) by Worstje
|
Message
| How about (assuming Lua):
if (a ~= b) and (b == c) then
Note("Bingo!")
end
Edit: note to self, reply faster. | Top |
|
The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).
To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.
19,194 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top