ID:264414
 
Code:
var/list/symbols = list("`","~","!","@","#","$","%","^","&","*","(",")","-","_","=","+",\
"\[","]","{","}",";",":","'","\"",",","<",".",">","/","?")

proc/Symbol_Check(t)
for(var/sym in symbols)
if(findtext(t,sym)) return TRUE
else return FALSE

mob/verb/Whatever()
var/a = input("","") as null|anything
if(Symbol_Check(a)) src<<"No symbols allowed"


Problem description:
For some reason, the verb is always succeeding, even when I enter symbols in for var/a >.< It works perfectly fine for my "number check" and it's the same exact thing, only it references a list that has the numbers 0-9. Any reason why my "symbol check" here won't work?
Spunky_Girl wrote:
Code:
> var/list/symbols = list("`","~","!","@","#","$","%","^","&","*","(",")","-","_","=","+",\
> "\[","]","{","}",";",":","'","\"",",","<",".",">","/","?")
>
> proc/Symbol_Check(t)
> for(var/sym in symbols)
> if(findtext(t,sym)) return TRUE
> else return FALSE
>
> mob/verb/Whatever()
> var/a = input("","") as null|anything
> if(Symbol_Check(a)) src<<"No symbols allowed"
>

Problem description:
For some reason, the verb is always succeeding, even when I enter symbols in for var/a >.< It works perfectly fine for my "number check" and it's the same exact thing, only it references a list that has the numbers 0-9. Any reason why my "symbol check" here won't work?

Try removing your else statement.
In response to Haywire
What the... now why on Earth did that work? >_>
In response to Spunky_Girl
Because of 2 facts:
1) You've used return in your else statement there without considering return's function. In other words, you didn't realize it causes only the first element in the symbols list to be processed/checked.
2) The purpose of your else return 0 line was ultimately unnecessary, as the proc would already return false by default anyway when it hit the end (and it'd only hit the end if a symbol wasn't matched). Albeit in that case it'd return [the default return value of] null, not 0, but that's still false so it doesn't make a difference.

In conclusion, that's why removing your 'else' line made the code work on Earth.