Raised This Month: $ Target: $400
 0% 

Concatenation of strings (putting two strings together)?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
OldWolf
Member
Join Date: Mar 2009
Old 04-11-2009 , 02:23   Concatenation of strings (putting two strings together)?
Reply With Quote #1

Howdy all,

I'm sure this is a no brainer, but I'm stumped:

I'm looping through a folder of maps. As each map is verified to be a legit map, I want to add it to a string in the following format (it's SQL if you're curious):

Code:
[some sql code will be here starting the string off, but it's not relevant]
('de_dust', 'foo', 'bar'),
('de_dust2', 'foo2', 'bar'),
('some_other_map', 'foo2', 'bar'),
('more_maps', 'foo2', 'bar'),
('zm_mansion', 'fooiest', 'bariest')
[The new lines aren't really in there, that was just to make it easier to see what I meant]

So where I stand right now is that I have the name of the map in a variable, and I can use the format function to put that name into the format of ('map_name', 'extra_value1', 'extra_value2')

Now, how do I add them to the existing list so they become one long string of value sets like that, with each separated by a comma (the last one shouldn't have a comma after it)?


Thank you!!!
OldWolf is offline
Emp`
AMX Mod X Plugin Approver
Join Date: Aug 2005
Location: Decapod 10
Old 04-11-2009 , 02:31   Re: Concatenation of strings (putting two strings together)?
Reply With Quote #2

Code:
new string[2001], iLen;
iLen += copy(string[iLen], (2001-iLen),		"Stuff");
iLen += formatex(string[iLen], (2001-iLen),	"Heres more stuff %s", szMoreStuff);
Code:
new list[2001], iLen;
iLen += formatex(list[iLen], (2001-iLen),		"'%s'", first_item);
for( new i; i<item_num; i++ )
	iLen += formatex(list[iLen], (2001-iLen),	", '%s'", other_items[i]);

Last edited by Emp`; 04-11-2009 at 02:36.
Emp` is offline
Send a message via AIM to Emp` Send a message via MSN to Emp` Send a message via Yahoo to Emp` Send a message via Skype™ to Emp`
OldWolf
Member
Join Date: Mar 2009
Old 04-11-2009 , 03:08   Re: Concatenation of strings (putting two strings together)?
Reply With Quote #3

Hey, that's just what I wanted!

My only problem:
I'm not sure what the length of the whole string might be after each data set has been added, since there's no limit to how many maps a server might have. Is there a way to make it open ended, or should I just set it to a really large number?

Thanks for getting back to me so quickly!
OldWolf is offline
Emp`
AMX Mod X Plugin Approver
Join Date: Aug 2005
Location: Decapod 10
Old 04-11-2009 , 04:06   Re: Concatenation of strings (putting two strings together)?
Reply With Quote #4

Could either use a large array, or you could use cellarray. I don't have much experience with it, and I don't think there is a tutorial on it, so you would have to look at other plugins that use it.
Emp` is offline
Send a message via AIM to Emp` Send a message via MSN to Emp` Send a message via Yahoo to Emp` Send a message via Skype™ to Emp`
OldWolf
Member
Join Date: Mar 2009
Old 04-12-2009 , 23:30   Re: Concatenation of strings (putting two strings together)?
Reply With Quote #5

Large array it is.

Hehe... I'm not lazy, I'm just really not sure what I'd be looking for. I can always upgrade it later when I learn more.. I'll look into it when I'm a little more experienced.

Thanks for your help!
OldWolf is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 02:24.


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