Blockland Forums > Modification Help
Tutorial on Str commands (strReplace)
<< < (3/5) > >>
otto-san:

--- Quote from: TripleNickels on April 23, 2011, 06:44:15 PM ---15 minutes is more than I've ever spent making a reply to a coding help topic.

--- End quote ---
i spent about an hour typing out a tutorial then it was all ruined by someone closing it


and the tutorial was basically the link posted.

i'm sure your help is appreciated, nobody is saying it wasn't any help at all.
Brian_Smith3:
So would:

--- Code: ---function isNumber(%str)
{
for(%i=0;%i<strLen(%str);%i++){
if(strCmp(getSubStr(%str,0,%i),"1234567890"))
return 1;
else
return 0;
}}}
--- End code ---
work? I wrote that on iPad. Help?
Destiny/Zack0Wack0:
The best way to check if something is a number is like this:

--- Code: ---function isInt(%string)
{
return %string $= mFloatLength(%string,0);
}

--- End code ---
But if you still want to do it your way, you'd do something like this:

--- Code: ---function isNumber(%str)
{
%len = strLen(%str);
for(%i=0;%i<%len;%i++)
{
%c = getSubStr(%str,%i,1);
if(strPos("123456789",%c) == -1)
return 0;
}
return 1;
}

--- End code ---
NOTE: Your way will not work for decimal numbers.
Brian_Smith3:
So mine is error free/will work? Hot!
Destiny/Zack0Wack0:

--- Quote from: Brian_Smith3 on April 24, 2011, 01:36:22 AM ---So mine is error free/will work? Hot!

--- End quote ---
It will not work for decimals.
EDIT: And no, the code I posted will. Yours has errors in it.
Navigation
Message Index
Next page
Previous page

Go to full version