Benoit Katecpo 2 Posted April 22, 2016 Hello ! I've got a problem, I want to compose a text from and array with a for or foreach structure, BUT, I wan't to put some color in my strings, and as you'll see it didn't seems to work ! Why ? I've tested 2 methods, one with the for structure, and the other one with a foreach structure, but in both cases, it didn't work ! No colors juste composed text :( Here is the 1st method : _txt = ""; for[{_i=0},{_i<(count arrayDump)},{_i=_i+1}] do { _slct = (arrayDump select _i) select 1; _slct = parseText format["<t color='#FF0000'>%1</t>",_slct]; _txt = format["%1 \n\n %2",_txt, _slct]; }; hint _txt; 2nd method : _txt = ""; { _slct = nil; _slct = (arrayDump select _foreachIndex) select 1; _slct = parseText format["<t color='#FF0000'>%1</t>",_slct]; _txt = format["%1 \n\n %2",_txt,_slct]; } forEach arrayDump; hint _txt; And arrayDump : arrayDump = [[1,"A"],[2,"B"],[3,"C"],[4,"D"],[5,"E"]]; In all case I have : A B C D E But no color :( How can I put a color ? Thanks in advance for your precious help ! Share this post Link to post Share on other sites
sarogahtyp 1108 Posted April 22, 2016 the only suggestion I have is to build the entire string unparsed and parse it at the end. _txt = ""; { _slct = (arrayDump select _foreachIndex) select 1; _txt = format["%1 \n\n <t color='#FF0000'>%2</t>",_txt,_slct]; } forEach arrayDump; hint parseText _txt; but idk if that works. Share this post Link to post Share on other sites
Neviothr 102 Posted April 22, 2016 Took a couple of hours, but I got it: arrayDump = [[1,"A"],[2,"B"],[3,"C"],[4,"D"],[5,"E"]]; _txt = ""; { _slct = nil; _slct = (arrayDump select _foreachIndex) select 1; _slct = parseText format["<t color='#FF0000'>%1</t>",_slct]; _txt = format["%1 <br/><br/> %2",_txt,_slct]; } forEach arrayDump; hint parseText format["<t color='#FF0000'>%1</t>",_txt]; Result: Share this post Link to post Share on other sites
Benoit Katecpo 2 Posted April 22, 2016 @sarogahtyp I'll try ;) @cx64 Thanks, but I've to color certain strings, sorry for inconvinience, I've not precise this, I'll try the first response and I'll tell you if it works ;) @sarogahtyp Thanks a lot !!! It works ! 1 Share this post Link to post Share on other sites
sarogahtyp 1108 Posted April 22, 2016 what do we learn from it? u cant parse structured text again because it doesnt contain the xml tags and is converted to default text settings. edit: thats nonsense ^^ edit2: i think the real reason is that u used format only without parseText as last operation on ur string before the hint. format returns just a string and not structured text as needed... instead of combineing format and parseText u can use formatText because its doing both in one. https://community.bistudio.com/wiki/formatText Share this post Link to post Share on other sites
Benoit Katecpo 2 Posted April 22, 2016 @sarogahtyp That's what I was thinking about ;) And I've another question, is there any way to put a text background color ? With parseText (It's XML, background-color='#FFFFFF' doesn't work :() Thanks in advance ;) Share this post Link to post Share on other sites
sarogahtyp 1108 Posted April 22, 2016 idk 8f this link helps... https://community.bistudio.com/wiki/DialogControls-Text Share this post Link to post Share on other sites
Benoit Katecpo 2 Posted April 22, 2016 @sarogahtyp Yes I've searched here ^^ But I want to put multi background color in one string ^^ Not just one for all structured text ;) Share this post Link to post Share on other sites