AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Copy one part of a string into another (https://forums.alliedmods.net/showthread.php?t=50525)

Ramono 01-28-2007 12:20

Copy one part of a string into another
 
Another help needed :)

I want to copy somthing from one string to another

Example:

Code:
new string1[]= "AA=hi,BB=hello,CC=hey,DD=sup,EE=anotherhi" new string2[10]

How to i find out what CC is and copy into string2.
Sounds simple but i cant figure it out.

[ --<-@ ] Black Rose 01-28-2007 12:43

Re: Copy one part of a string into another
 
Code:
new string1[]= "AA=hi,BB=hello,CC=hey,DD=sup,EE=anotherhi" new string2[10] find_value(string1, "CC", string2, 9) find_value(in_string[], _for[], value[], outlen) {     new len = strlen(in_string), len2 = strlen(_for)     new pos, templen         while ( pos != len - len2 ) {         if ( equal(in_string[pos], _for, len2) ) {             pos += len2 + 1             while ( in_string[pos] != ',' && templen < outlen && pos < len ) {                 value[templen] = in_string[pos]                 templen++                 pos++             }             break         }         pos++     } }

Ramono 01-28-2007 12:53

Re: Copy one part of a string into another
 
It works!!

You just made my day, thx ++k


All times are GMT -4. The time now is 00:35.

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