Jump to content
Mr H.

getArray with booleans in the array

Recommended Posts

ok let's say you have an array containing booleans in a configfile something like:
 

class myCfg
{
	class Test
	{
		myarray[]={true};
	};
};

now the getArray command will return... a string inside the array instead of a boolean.

 

getArray (missionConfigFile>>"myCfg">>"test">>"myArray) //Retuns ["true"]

I was wondering if someone knows of an alternative function/command that will return arrays with "real" BOOL instead ?

Share this post


Link to post
Share on other sites

Use number (0 or 1) instead or convert "true" string to true boolean by using call compile.

  • Like 1

Share this post


Link to post
Share on other sites
2 minutes ago, POLPOX said:

Use number (0 or 1) instead or convert "true" string to true boolean by using call compile.


I'll do that eventually yes but it's a shame there's no engine solution for that issue.

Share this post


Link to post
Share on other sites
8 hours ago, POLPOX said:

convert "true" string to true boolean by using call compile

Just use apply, rather than compiling the string.

 

Bools stored as numbers.

TAG_fnc_getBoolArray = {
   params[ "_path" ];

   getArray( _path ) apply{ _x > 0 };
}

Bools stored as strings.

TAG_fnc_getBoolArray = {
   params[ "_path" ];

   getArray( _path ) apply{ _x == "true" };
}

 

  • Like 2

Share this post


Link to post
Share on other sites

You can write arr[]={quitetrue} and it will return ["quitetrue"] because for config parser `everything that is not a number must be string`

  • Like 1

Share this post


Link to post
Share on other sites
6 hours ago, Larrow said:

Just use apply, rather than compiling the string.

 

Bools stored as numbers.


TAG_fnc_getBoolArray = {
   params[ "_path" ];

   getArray( _path ) apply{ _x > 0 };
}

Bools stored as strings.


TAG_fnc_getBoolArray = {
   params[ "_path" ];

   getArray( _path ) apply{ _x == "true" };
}

 

Simple/ elegant / perfect!

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

×