ID:174239
 
heres my list

var/list/IllegalChars = list("1","2","3","4","5","6","7","8","9","0","{","}","(",")" ,"!","@","#","$","%","^","&","&","*","_","-","+","=","|","\\","\[","\]",",","<",".",">","?","/","\'","\"","`","~"," ")

heres where Im tryin to use it

if(findtext(First_Name, IllegalChars,)==0)

else
usr << "Names cannot contain numbers, special characters, or spaces"
goto Name

First_Name is entered as text a few lines above everything works up until this point. After I enter a name, regardless of what it is, it always gives the Names cannot contain such and such msg and goes back to Name which starts the process over again, regardless of what First_Name actually is. I dunno if its cause the list isnt gettin looked thru like its spose to and thats causin the error or if its somethin wrong with my findtext proc. But I took it from the F1 help example for findtext and just changed it for my vars. Ive even made a test verb usin the example findtext but allowin me to enter the string and the string to search for and it works flawlessly thats what leads me to believe its my list not gettin used right so I decided to ask here since I cant figure out how to do it.

You can't use findtext() with a list like that; you'd have to loop through items in the list to do that.

Much much easier is to loop from 1 to length(name) and use text2ascii(name,index) to find the ASCII value of each character, then quickly check it against ranges of legal or illegal values.

Lummox JR
Ok, what you've got is pretty good. Except where you have findtext(First_Name, IllegalChars,)==0 you're not giving it anything to look for you're just giving it a list (And you have a "," after IllegalChars where it isnt needed, so get rid of that).
What you need to do is scroll through IllegalChars and check to see if each of the things inside it can be found in First_Name.
For this we will use a for() loop. for() is one of the most useful proc in almost any language, I suggest you look it up later.
for(var/Char in IllegalChars)
if(findtext(First_Name, Char)!=0)
usr << "Names cannot contain numbers, blablabla"
goto Name

Ok, what this has done is made a loop that goes through each of the entries in IllegalChars, puts them in the 'Char' variable, then checks to see if they can be found in First_Name. Then goes to Name if it finds anything.
Now you'll notice that Ive changed ==0 to !=0. Basically != means doesn't equal.

I hope this helps. Its a little long winded, and Im not too good at explaining things. If you have any problems just ask, and if you don't have any problems I suggest you take a look at the reference entries for "for()", "while()", "!", and "cKey()"/"ckey()". They are all very useful.


[Edit] Doh, Lummox JR already helped 20 minutes ago... I shouldn't have went to get something to eat =P
Oh well, I'll leave this here in just in case you find it useful.
In response to Lummox JR
ok I think I got that but how do I check to see if the character of the name is found in the list?

Heres what I got right now

FindText(M as text)
var/i //index
var/S //Search char
var/C //Illegal char
for(i=1, i<=length(M), i++)
S = text2ascii(M, i)
for(i=1, i<=IllegalChars.len, i++)
C = IllegalChars[i]

if (S == C)
usr << "[S] found at [C]"
else
usr << "[S] not found"

It always says not found. I changed my list to all be text2ascii values of all the chars I want to be illegal so its all number checking but I dunno whats wrong lol

In response to DarkView
Oddly enough I had been tryin to Lummox code workin and I couldnt do much with it I replied for help with what he said and saw your post and used your method and had it workin in about 2 min. So yeah Id say I found it helpful =) Tyvm
In response to Aridale
During your index loop, right after the S=text2ascii(M,i) line, you need to check S against a few sets of values. In this case, if(S<65 || (S>90 && S<97) || S>122), then you've got an illegal character.

Lummox JR