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 Color.black command.
Thank you
Lou
How to apply color properties
Re: How to apply color properties
The Color.black 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.
philip
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.
philip
philip
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:
Code: Select all
$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
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.
Lou
Lou