Copy link to clipboard
Copied
Hi. Using ID 19.0.1 with Win 11/updated.
I've used a text variable for the product name: "use a <Vapid-20> thingie to...." Why? The client likes to change the names of things mid-project.
But they got me this time. They changed it to a name beginning with a vowel. Now it's the <Avapid-20>. I can instantly change the product name everywhere by editing the variable, but everywhere I said "use a Vapid-20" it now has to be "use an Avapid-20." English.
Is there any way to search/find a text variable?
I suppose I could then use GREP or even scripting to change the word just before it if needed... but I have to find it first.
As always, thanks to the community.
-j
You can find search the text variable. you just click on the @ drop down next to the text field and insert the correct special character for your variable. The problem is that you can not replace with a text variable. So either you would have to replace your text variable with the actual text for the name, or you would need to just search and manually adjust the article.
Copy link to clipboard
Copied
You can find search the text variable. you just click on the @ drop down next to the text field and insert the correct special character for your variable. The problem is that you can not replace with a text variable. So either you would have to replace your text variable with the actual text for the name, or you would need to just search and manually adjust the article.
Copy link to clipboard
Copied
This is a 98% solution -- thanks. I did not know this existed. I'm using several custom-text variables, and this finds them all... but it's better than searching for the letter "a." 🙂
-j
Copy link to clipboard
Copied
You could get 100% with Robert's suggestion of checking the textVariableInstances for the correct variable and then checking in the parent text object of the correct variable for an " a " at it's index-3. then you would have to insert the "n" at it's index-1 of the parent text object.
Copy link to clipboard
Copied
You could get 100% with Robert's suggestion of checking the textVariableInstances for the correct variable and then checking in the parent text object of the correct variable for an " a " at it's index-3. then you would have to insert the "n" at it's index-1 of the parent text object.
By @John D Herzog
I don't think it will work that way ...
Variable is an object - kind of InLine TextFrame - and you can't just refer to its name like it is a part of the main text:
Green marked "AAAAA" is a Text Variable - and it is a single Character.
Also, you can't refer to it by its index as this is a location in the TextVariableInstances collection - you would have to refer to it as a StoryOffset - which is an InsertionPoint:
And next Character would be a "location" of the Variable...
Copy link to clipboard
Copied
And here is more detailed view - by Characters:
or by Words:
It's always a single Character.
Copy link to clipboard
Copied
Sorry. I overgeneralized. I will spell it out better without getting into the complete coding of the problem.
Find the your textVariable in the array of textVariables for the document.
Take the associatedInstances (another array) of your textVariable and check in their parent before their storyOffset.index for " a ".
if the " a " is found place an "n" after the "a" in the " a ".
You could go a step further and check the associatedInstances.resultText for a vowel or consonant at the begining. Depending on the answer adjusting to an "a" or "an" as needed.
Copy link to clipboard
Copied
OK, I've misunderstood OP's post - and now your answer @John D Herzog makes sense.
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Maybe a different approach - a bit simpler and more bullet proof solution - two variables?
One, when product's name is "alone" - like in the title.
Another - when in text - so you can add "a" or "an" as part of the variable's content?
Copy link to clipboard
Copied
Was thinking about that as well. We just don't know how many text variables they are already juggling. We know it is more than just the product name. If they have a lot of them, a simple script that checks the first letter of all their variables might cause less headaches.
Anyway this is all theoretical since I think the OP is done with this topic.