AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   How to concat a strings? (https://forums.alliedmods.net/showthread.php?t=234566)

Kapuzzino 02-01-2014 08:06

How to concat a strings?
 
subj.

devilicioux 02-01-2014 08:29

Re: How to concat a strings?
 
You can use Format or Formatex .. Latter 1 is faster.. Search the forum .. You will find infinite usage tuts..

Kapuzzino 02-01-2014 08:32

Re: How to concat a strings?
 
@devilicioux, is that so heavy? Why I can't use just

PHP Code:

new myStr1 "Test";
new 
myStr2 "string";

myStr1+=myStr2


YamiKaitou 02-01-2014 08:35

Re: How to concat a strings?
 
Because strings are Arrays, not single cells.

devilicioux 02-01-2014 08:38

Re: How to concat a strings?
 
May be you can try Strcat() as well .. Not sure..
But Formatex() is the best option available.

Here you have the example and explanation ..

Quote:

Originally Posted by sawce (Post 594374)
formatex() is almost identical to format(), however, if the destination of the string also contains one of the parameters, undefined results will occur.

PHP Code:

new buff[256];
new 
name[32];
new 
authid[40];

get_user_authid(idauthidcharsmax(authid));
get_user_name(idnamecharsmax(name));
formatex(buffcharsmax(buff), "%s<%s>"nameauthid); 



Kapuzzino 02-01-2014 08:42

Re: How to concat a strings?
 
I need to do it in a cycle, thats why I need a concat, instead of formating two strings.

when the socket_change, than I need to put each time string into a html variable:

PHP Code:

    new html// will contain a whole page.
    
if (socket_change(g_Socket)) 
    { 
        
socket_recv(g_Socketg_Data1023
        
html+=g_Data// wrong example
    



YamiKaitou 02-01-2014 08:47

Re: How to concat a strings?
 
Try using add or format. Make sure that the length of the variable is large enough to contain both strings though

Kapuzzino 02-01-2014 08:55

Re: How to concat a strings?
 
@YamiKaitou it's the add function, and I have error, such as you can see after code line

PHP Code:

add(html,charsmax(g_Data),g_Data,charsmax(g_Data)) 

errors:

Error: Argument type mismatch (argument 1) on line 85

Black Rose 02-01-2014 09:02

Re: How to concat a strings?
 
Looks like your html variable is not an array.

Code:
new html[128] add(html, charsmax(html), g_Data)

YamiKaitou 02-01-2014 09:03

Re: How to concat a strings?
 
html MUST be an array. All Strings are Arrays with a fixed length, you cannot have a dynamic length for a string.


All times are GMT -4. The time now is 15:42.

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