Other_text_colour

Posted by Rene on Wed 03 Jan 2018 01:40 AM — 4 posts, 19,370 views.

#0
I am trying to set a trigger to colour the text in a colour different than a custom colour. It seems the way to do this is with SetTriggerOption, yet it is not working.
Here is the lines in the code:

	AddTrigger("Name", "Rene", "", trigger_flag.Enabled + trigger_flag.RegularExpression + trigger_flag.KeepEvaluating + trigger_flag.IgnoreCase, -1, 0, "", "")
	--Set to repeat on same line
	SetTriggerOption ("Name", "repeat", "y")
	IfErrorCode = SetTriggerOption ("Name", "other_text_colour", "magenta")

However it returns an error, 30026, which the site says is out or range, why is it not working?
Thanks.
Amended on Wed 03 Jan 2018 01:41 AM by Rene
Australia Forum Administrator #1
Two things here.

First, the documentation for SetTriggerOption is wrong. The option "other_text_colour" is supposed to be a number, not a string. Thus you should use ColourNameToRGB to convert the string "magenta" to its appropriate colour code.

This documentation will be updated in the next release.

For example:


IfErrorCode = SetTriggerOption ("Name", "other_text_colour", ColourNameToRGB "magenta")





Second, this option is not for colour matching, it is for setting the matching text to some colour. You want option "match_style". See http://www.gammon.com.au/forum/?id=4873 for more information about that.

However the style only matches ANSI colours. The field for matching is only 4 bits for foreground and 4 bits for background, so you can only match the following colours:


BLACK = 0
RED = 1
GREEN = 2
YELLOW = 3
BLUE = 4
MAGENTA = 5
CYAN = 6
WHITE = 7





To solve your problem you need to match (regardless of colour) and then test the colour of the matching text. See the post http://www.gammon.com.au/forum/?id=7818 for how to get the colour of a particular part of the line you matched on. You can then disregard any lines that don't match that colour.
#2
Thanks, I meant changing the text colour like your first response, unsure why you understood me differently.
Either way, it didn't work for me, yet I found if I do this:

SetTriggerOption( "Name", "custom_colour", tostring(17))
IfErrorCode = SetTriggerOption ("Name", "other_text_colour", ColourNameToRGB "magenta")


Then it worked, unsure why that is.
Amended on Wed 03 Jan 2018 10:36 PM by Rene
Australia Forum Administrator #3
Sorry for the misunderstanding. I thought you were asking about matching a colour, don't quite know why. :)

You need to set the colour type to "other" like you did (I don't think the tostring is neccessary):


SetTriggerOption( "Name", "custom_colour", 17)


As documented, that is "use other colour":

Quote:

"custom_colour": 0=no change, 1 - 16, 17=other


Then your second line defines what the other colour is.