Jump to content
Sign in to follow this  
DZR_Mikhail

Convert string to array (call compile?)

Recommended Posts

Hi. All AAR development now stopped because I couldn't make an array out of string. Please help! :butbut:

So I read a string from external source (a named pipe) and it looks like this:

[9.386,q_11,[4224.73,3247.1,0.00175858],313.83,'0']

I read it to _ddata variable. So in theory in arma it could look like this:

_ddata = "[9.386,q_11,[4224.73,3247.1,0.00175858],313.83,'0']";

and we need to make it an array, actually I need it to be the same but without the string quotes:

_ddata = [9.386,q_11,[4224.73,3247.1,0.00175858],313.83,'0'];

I try to do this using call compile, but I never used this command and I think I make mistakes in the syntax.

call compile "_ddata_array = _ddata;";

That last piece of script is the point I fail with. Without the conversion the AAR won't be able to playback. HALP! :butbut:

Share this post


Link to post
Share on other sites

You could try using toarray and tostring. There is parseNumber as well.

I was only using them to change strings around, but it would allow you to search through the string and pull out each element. You could then do a check with the unicode values to see if they are numeral types plus decimal point and minus sign to then convert into a number with parseNumber.

Not tried it to this depth, but could be a solution for you. Or a start maybe.

Hope it helps.

http://community.bistudio.com/wiki/toArray

http://community.bistudio.com/wiki/toString

http://community.bistudio.com/wiki/parseNumber

Edited by blakeace

Share this post


Link to post
Share on other sites

Thanks, I hope there will be a more subtle solution. All those UNocode conversions will make it very difficult... There will be like 20 arrays every 0.01 second and reparsing them I think will impact performance very much.. .I hope for call compile method (((

Share this post


Link to post
Share on other sites

Oktane says that will do the trick

call compile format["_ddata_array = %1", _ddata]; 

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
Sign in to follow this  

×