AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Read multiple Integers from one String (https://forums.alliedmods.net/showthread.php?t=45614)

Silencer123 10-07-2006 08:37

Read multiple Integers from one String
 
Code:
public something() {     new string[64] = "123#456#789"         new first = ? // Shall read the Stuff before first "#" from "string" and convert it into a Number. (123)     new second = ? // Shall read the Stuff betweem the first and the second "#" from "string" and convert it into a Number. (456)     new third = ? // Shall read the Stuff after the last "#" from "string" and convert it into a Number. (789) }
How to?
Thanks in advance!

MaximusBrood 10-07-2006 09:11

Re: Read multiple Integers from one String
 
Two ways:

Code:
new string[64] = "123#456#789"; new splitString[12]; new num1, num2, num3; strtok(string, splitString, 11, string, 63, '#'); num1 = str_to_num(splitString); strtok(string, splitString, 11, string, 63, '#'); num2 = str_to_num(splitString); num3 = str_to_num(string);

Code:
new string[64] = "123#456#789"; new strNum1[12], strNum2[12], strNum3[12]; new num1, num2, num3; replace_all(string, 63, "#", " "); parse(string, strNum1, 11, strNum2, 11, strNum3, 11); num1 = str_to_num(strNum1); num2 = str_to_num(strNum2); num3 = str_to_num(strNum3);

Silencer123 10-07-2006 11:06

Re: Read multiple Integers from one String
 
Thanks alot!


All times are GMT -4. The time now is 04:44.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.