colobot-data/help/D/cbot/strval.txt

20 lines
869 B
Plaintext

\b;Instruction \c;strval\n;
Convert a string to a number. Don't confuse the string \c;"45"\n; that contains actually the two characters \c;4\n; and \c;5\n; and the number \c;45\n;.
Examples¦:
\s;\c; string s = "45"+"12"; // s contains "4512"
\s; float n = 45 + 12; // n contains 67
\n;
Syntax¦:
\s;\c;strval ( string );\n;
\n;
Examples¦:
\s;\c; float n = strval("1.23"); // n is 1.23
\s; float n = strval("12abc45"); // n is 12
\s; float n = strval("abc"); // n is 0
\s; float n = strval("100")+2; // n is 102
\n;
\t;See also
\c;\l;strlen\u cbot\strlen;\n;, \c;\l;strleft\u cbot\strleft;\n;, \c;\l;strright\u cbot\strright;\n;, \c;\l;strmid\u cbot\strmid;\n;, \c;\l;strfind\u cbot\strfind;\n;, \c;\l;strupper\u cbot\strupper;\n;, \c;\l;strlower\u cbot\strlower;\n;
\l;Programming\u cbot;, \l;types\u cbot\type; and \l;categories\u cbot\category;.