SphereCommunity
About strings - Printable Version

+- SphereCommunity (https://forum.spherecommunity.net)
+-- Forum: Sphere 0.56d (/Forum-Sphere-0-56d)
+--- Forum: Script Help (/Forum-Script-Help)
+--- Thread: About strings (/Thread-About-strings)



About strings - Dullais - 03-19-2013 08:11 AM

Hello guys, I'am making my vendor system and i cant find any way to check if string contains only numbers (0-9). Is there a way to check for it ? (i need this one for prices.


RE: About strings - Fahrenait - 03-19-2013 08:36 AM

for 0 <eval strlen(<argtxt[1]>) -1>
if !strmatch('[0-9]','<strsub <eval <local._for>> 1 <argtxt[1]>>')
sysmessage just number..
return 1
endif
endfor

// argtxt from dialog


RE: About strings - Mordaunt - 03-19-2013 08:55 AM

if strregex(^[0-9]+$,<argtxt[1]>)


RE: About strings - Dullais - 03-19-2013 10:36 PM

(03-19-2013 08:55 AM)Mordaunt Wrote:  if strregex(^[0-9]+$,<argtxt[1]>)

I dont really understand tht line, but thanks Smile It works Smile


RE: About strings - admin phoenix - 03-19-2013 11:03 PM

what about
if <isnum <args>>
???


RE: About strings - Mordaunt - 03-19-2013 11:04 PM

It's new to me also, used it for the first time last weekend.

http://wiki.sphere.torfo.org/index.php/Chapter_10#STRREGEX


RE: About strings - Gil Amarth - 03-20-2013 12:40 AM

Yes, but why not using ISNUM?
Then a conditional if <ARGS> < 0 or > 10?

That line with strregx is amazing, but the easy way is also useful. xD