How to apply color properties
Page 1 of 1

Author:  loulesko [ 2009-06-01 03:02:48 ]
Post subject:  How to apply color properties

Sorry to bother, but the Macro Reference is a little light on examples and I'm not a programmer. If I have a variable $value and I want to make all the text in that variable black, how to I apply the command.

Thank you

Author:  phspaelti [ 2009-06-01 05:10:51 ]
Post subject:  Re: How to apply color properties

The command is a command which returns a constant. The result is a rgb value (0,0,0). You can use this in commands like the "Set Text Color" command. That command assigns the color value to the current selection.

In your case, I am guessing, the $value is not the current selection, but maybe a variable that you have created? Ideally one could set the attribute properties of such a variable directly, but the way I understand the manual, attribute properties are read only at the current time. So you will probably have to set the color at the time when you want to insert into your file.


Author:  Kino [ 2009-06-01 07:28:19 ]
Post subject:  Re: How to apply color properties

Well, attributes objects are read-only. As a workaround, you can convert $value (styled text) into RTF data, replace all colour definitions in the colour table with that of black, and convert the data into styled text again:
$value = Encode RTF $value
$value = Cast to String $value
$value.replaceAll '(?<=;)\x5Cred\d+ \x5Cgreen\d+ \x5Cblue\d+(?= ;)', '\x5Cred0 \x5Cgreen0 \x5Cblue0', 'E-i'
$value = Decode RTF $value

Author:  loulesko [ 2009-06-04 08:06:15 ]
Post subject:  Re: How to apply color properties

Thank you all for your replies. After some tooling around, my solution distilled down to some very simple steps which uses the :Format:Text Color command.


Page 1 of 1 All times are UTC - 8 hours
Powered by phpBB® Forum Software © phpBB Group