Jump to content

Recommended Posts

Hello everyone,

 

here is a really simple function that I put together:
 

/*
	Author: Terra

	Description:
	Converts the elements of an array into a string

	Parameter(s):
	0: ARRAY - array of elements of any type
	1 (Optional): STRING - seperator between elements (default: ", ")

	Returns:
	STRING
*/


params [
	["_array", [],[[123]]],
	["_seperator", ", ", ["123"]]
];

_str = format ["%1", _array select 0];
{
	private _addString = _x;
	if (typeName _addString != typeName "123") then {_addString = str _addString};
	_str = _str +_seperator +_addString;
} forEach (_array -[_array select 0]);
_str

 

Just some code that I wrote down while working on another project. Feel free to modify and comment.

  • Like 1

Share this post


Link to post
Share on other sites

There's also the

_array joinString _separator 

which does the same thing.

  • Like 5

Share this post


Link to post
Share on other sites

Oh. I knew there was this command but I barely used it. Well then nevermind :)

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×