Director lingo Q?
- Started
- Last post
- 26 Responses
- Seph
I am calculating values from editable text fields entered by the user, I need to make sure the values are only numerical before submitting them. How can I check this in lingo?
I.e
if the text of member "field" contains _________ ? then
alert "you have entered a non numeric value, please try again using a numeric value"
else
submit()
end if________? what can I put here that defines the value as a letter and not a number
- unknown0
If you do this...
put integer(member ("thetext").text )and the text is a number it retuen a number... but if it is 'blah' for example it returns a void... hope that helps
- curtis0
on exitFrame me
temp = 2000
put ilk(temp)
go the frame
end
change temp to a string and see the change in the message window . . .
hope this helps
:)
- unknown0
that's probably better... haven't used director for about 6 months :S
- Seph0
thanks guys, trying them now.
- Seph0
curtis,
ilk only tells me if its already defined as a string or an integer, not if a string contains numeric values.
- unknown0
go with the work around... always works...................
.... around >:S
- Seph0
Thanks both of you for your help.
Engage, that seems to work nicely. respek !
- curtis0
yeah, I see what you mean. It's always a string when you pull the value in from the text member, right?
hmmmmmmm . . .
I'll have a play
- curtis0
ah - fair play engage!
- Seph0
Its moments like this I love NT.
I love you too curtis and Engage, just for knowing lingo, and being clever.
Big love.
- Seph0
NO !!! I just realised, if I put a decimal point in the value then it all goes tits up.
Its a float, accurate to 1 decimal place.
hang on I have an idea.....
- curtis0
awwwwwww. . .
*blushes
- Seph0
unfortunately
put float(member("thetext").text)
doesnt return a void if theres a char in it.
)-:
- Seph0
curtis, help me love.
- unknown0
I'd check the value see if it has one or less decimal places.. i.e search for '.' if it does then remove it and do the intger thing on it... if it hasn't it's not a number anyway
- Seph0
which is exactly what I just did Engage !! you young spark you, and it worked. here it is out of interest :
on exitFrame me
if member("thetext").text contains "." thenmyvalue = string (member("thetext").text)
set charcounter to the number of chars in myvaluerepeat with i = 1 to charcounter
if myvalue.char[i] = "." then
delete myvalue.char[i]
end if
end repeatif integer(myvalue) = void then
put "bad value!!!!"
else
put "submit!!!"
end ifelse
if integer(member("thetext").text) = void then
put "bad value!!!!"
else
put "submit!!!"
end if
end ifend
- curtis0
try making the decimal point an item delimiter. then check to see if the string has more than one item - if it does, alert:
"No, no, NO!"
or something similar . . .
- Seph0
fuck ! Very nearly there.
but then thats not perfect either because it doesnt check for symbols other than chars, such as @ or = or _ but at the end of the day, who enter symbols deserves everything they get the idiots.
- unknown0
just do an extra check for weird characters at the start... and alert 'stop playing silly buggers'
- Seph0
Curtis, I like what your saying, Ill try that.