I have a script that creates a color, applies it to a particular property of a number of styles (one after the other) and then searches for that property. This works just fine the first time I run it in an InDesign session, and usually the second and third times as well. However, at some point I find that it stops working, because when the color is assigned to the findTextPreference property it is assigned as a string that gets some numbers after it. So, I do something like this:
var myColor = myDoc.colors.itemByName("testCol");
myCSty.underlineGapColor = myColor;
app.findTextPreferences.underlineGapColor = myColor;
However, if I then query app.findTextPreferences.underlineGapColor, it is a string, and that string will be something like "testCol 3" (it iterates upwards depending on how many times I've run it during a session). I can't change the string; assigning NothingEnum.NOTHING to the property and then reassigning the color just iterates the number again. In fact, even if I try to assign that color to a different color property, or to a findGrepPreferences color property, it continues to iterate the number. I so far have not been able to recreate this problem in a less complex script (I'm still trying), but I was hoping someone might have encountered this and might have some guidance.
I thought that the problem might be related to the bug discussed here: fillColor in find/change Preferences in indesign cs3 so I started adding my colors at the app level as well. This doesn't seem to hurt anything, but it doesn't help either. And trying to assign the color whose parent is app to my findTextPreferences property just gives me the error seen there (I guess that means the bug was fixed? I'm not sure.)
Is there any way to force the findTextPreferences properties to accept an object rather than converting that object into a string? Or is my problem too vague and unrepeatable to help at this point?
Upon further testing of this, it seems like the issue is rooted in one particular document which, if open, can experience this problem or cause it to occur in other documents (like it's polluting the session). I have no idea why, but since I can't provide the file it's not something anyone is likely to be able to recreate or help me with. Not sure if I should delete my question or close it, or what.