Jump to content
Sign in to follow this  
Kydoimos

CopyToClipboard Help

Recommended Posts

Hi all! I've had a hunt for related threads, but I couldn't find anything to help. Basically, I'd like to know how to copy a script to the clipboard. I've tested copyToClipboard "Working", and it does the job. However, I'd like to include line breaks. As well, when I want to copy text which contains speech marks (example, Lamp_01 = "Land_Camping_Light_F" createVehicle getMarkerPos "_Marker") how do I do that? As the first speech mark will end the copied text - does that make any sense? God, sorry. I found this on line breaks: https://community.bistudio.com/wiki/copyToClipboard, but Benargee's comment didn't seem to work for me. Any ideas? Thanks all! :)

Share this post


Link to post
Share on other sites

You could do a mixture of parseText and format(maybe):

copyToClipboard parseText (format ["%1",_var)];

May need to compile the script stuff first.

Edited by JShock

Share this post


Link to post
Share on other sites

copyToClipboard (preprocessFile "myScript.sqf");

Note: this doesn't do anything to add line breaks

You could do a mixture of parseText and format(maybe):

probably a low chance of this working, it looks like copyToClipboard can only work with strings

Share this post


Link to post
Share on other sites

_newline = toString [0x0D, 0x0A];  // [Carriage Return, new line]
copyToClipboard format ["some text %1some more %2third line",_newline,_newline];

And use double quotes "" if you want the string to contain only one -> format ["Lamp_01 = ""Land_Camping_Light_F"" etc. %1",_newline];

If you're copying many lines, remember that you can combine strings to keep the code readable:

copiedstring = format ["first line %1second line %2",_newline,_newline];
copiedstring = copiedstring + format ["third line %1 ""Land_Camping_Light_F"" %2",_var,_newline];
copiedstring = copiedstring + format ["last line%1",_newline];
copyToClipboard copiedstring;

edit. oh, that was mentioned in the wiki already. :)

Edited by Greenfist

Share this post


Link to post
Share on other sites

Thanks chaps! Really helpful! Always appreciate it! :D

Share this post


Link to post
Share on other sites

Well, I based my note off of official BIS functions that I went through.

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  

×