strval - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: strval (
/showthread.php?tid=423905)
strval -
Fergy - 19.03.2013
Hello,
what is return in strval() when:
new value = strval("test");
?
Thanks
Re: strval -
ReVo_ - 19.03.2013
https://sampwiki.blast.hk/wiki/Strval
in your case, will be 0.
Re: strval -
Bakr - 19.03.2013
pawn Код:
#include <a_samp>
main() { printf("value: %i", strval("test")); }
Oh..lazy people.
Re: strval -
Fergy - 19.03.2013
Oh no... Is there any function like IsString ?
Re: strval -
Jstylezzz - 19.03.2013
You can make one, try this for example:
pawn Код:
IsNumeric(const string[])
{
for (new i = 0, j = strlen(string); i < j; i++)
{
if (string[i] > '9' || string[i] < '0') return 0;
}
return 1;
}
Use this to check if a string is numeric.
Re: strval -
Fergy - 19.03.2013
Thanks
Re: strval -
LarzI - 19.03.2013
I recommend using the version from y_utils as it's about 3 times as fast (Benchmarked with 10000 loops, your version took 9ms while this one only 3ms - the difference is pretty unnoticable, but still):
pawn Код:
stock isnumeric(str[])
{
new
ch,
i;
while ((ch = str[i++])) if (!('0' <= ch <= '9')) return 0;
return 1;
}
Re: strval -
mastermax7777 - 19.03.2013
Quote:
Originally Posted by LarzI
I recommend using the version from y_utils as it's about 3 times as fast (Benchmarked with 10000 loops, your version took 9ms while this one only 3ms - the difference is pretty unnoticable, but still):
pawn Код:
stock isnumeric(str[]) { new ch, i; while ((ch = str[i++])) if (!('0' <= ch <= '9')) return 0; return 1; }
|
or just use y_faster_everything_because_we_are_obsessed_with_s peed_plugin