Jump to content
Sign in to follow this  
Rydygier

Tabs lost in 'strings' when after new line

Recommended Posts

Don't know, if a question or rather an observation... I'm writing a script working on strings, that changes them and returns changed. All is going fine except mainly one thing:

_string = "	
";

copyToClipboard _string;

diag_log format ["%1 %2 %3 x%4x",toArray _string,toArray copyFromClipboard,toArray (_string select [0]),_string];

/*return is good: "[9,10,9] [9,10,9] [9,10,9] x	
x"*/

but:

_string = '	
';

copyToClipboard _string;

diag_log format ["%1 %2 %3 x%4x",toArray _string,toArray copyFromClipboard,toArray (_string select [0]),_string];

/*return: "[9,10] [9,10] [9,10] x	
x" - second tab vanished*/

So, it's intentional difference between "string" and 'string' or some issue?

Share this post


Link to post
Share on other sites

Hm, interesting. I know some scripting languages that handle single and double quotes differently but I don't think SQF does that. The String entry on the BIKI doesn't mention anything about it so you may have stumbled upon a bug.

Share this post


Link to post
Share on other sites

Thanks for finding this. Might prevent some headaches for people in the future. :)

Share this post


Link to post
Share on other sites

I apologize for revisiting this old thread, but I'm here to confirm that this behavior is still happening and to offer a solution:

Through use of the toString command, we can create tabs/newlines on-the-fly.

toString [9] will create a tab

toString [10] will create a new line

Any combination can be created with this.

I tested this code:

copyToClipboard format ['x%2x',toString [9,10,9]];
/*
correctly returns:
x	
x
*/

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  

×