WeatherGraphics: Ace,
I do not want to sound ungrateful, because I really do appreciate any and all assistance I get from this and others forums, but two things:
Firstly, could you actually explain why you consider the construct to be strange.
As all we are aiming to do is compile a list of Text boxes in which the
string appears, and not every individual instance of the string, it
does not necessarily look like strange syntax to me. Despite the fact
that it obviously does not work ;)
I find it starnge because "text" (in Quark's view) is not a finite entity as opposed to words or paragraphs for instance.
Now consider the following statement:
set RefList of object reference of every text of every story where it is "foo"
This will returns a list of occurances of the the string foo whitin every story of your document (each item being in the for of: text from character x to character y of story z of document 1)
So TEXT is simply a string that has no delimiter other than the one you specify. Reading this, it stand to reason that there are other TEXT within those stories BUT my script chose to ignore them.
Now, on to your construct:
set allTextBoxes to (object reference of every text box whose every text contains beginTag)
What I do find peculiar, as I mentioned before, is the use of EVERY TEXT CONTAINS. Since we know there are an infinite number of TEXT within a story. Asking to get a list of text boxes whose EVERY TEXT contains certain character is very strange to me.
Let say you are at the market and come accross boxes containing fruits. If you wanted to get the boxes that contains apples you would not ask the farmer:
Please tell me which box whose EVERY fruit is an apple?
If he does not have a box ONLY filled with apples, he will simply say "I have none".
WeatherGraphics:Secondly, we could definitely use your code, though we do have a similar work around code that does produce the required result, which from your above example would be:
{
text box 1 of page 1 of document "Project2",
text box 2 of page 1 of document "Project2"
}
We would have to filter out all duplicates, and isolate just the object reference of the text box, the text reference is of no importance.
Truly thank you for helping me out with this!
Cristian..
Than you should use the part of the code that deal with UniqueID. Your previous code worked with standard text box reference like the ones you just mentioned BUT you can also use its UniqueID for the "targetting" process.
Now my BoxListIDs does rmove duplicates and you could use it to target each box only once
OR
You could also go through the BoxListRefs (which MAY congtain duplicates) and at the start of each iteration check to see if its UniqueID has already been processed:
001 set Processed_IDs to {}
002 repeat with ThisBox in BoxListRefs
003 set BoxID to uniqueID of ThisBox
004 if Processed_IDs does not contain BoxID then
005 -- do your stuff here
006 set end of Processed_IDs to BoxID
007 end if
008 end repeat
Notes:
• The line numbers included with this script are there to aid future discussions. In order to use this script, you will have to strip all of them.
HTH