4 Replies Latest reply on Mar 1, 2011 2:55 PM by CarlJones






      I have a key work in a document that I would like to serialize. Say I have a document with 100 pages and the word "Static" is mentioned often.  I want to use each occurance, therefor I would like to automatically add a number after each occurence of the word "static" and is serial. I have been trying to use the function that appears to let the user type in a word and increment, however, I have not been able to get it working. Any help would be appreciated. Thanks


        • 1. Re: Serialize

          So to serialize "Apple" in this text: The apple doesn't fall far from the Apple tree.

          You want to see The Apple 1 doesn't fall far from the Apple 2 tree. ?

          A script that loops through all the text in a field one word at a time could be used to do this, though it won't happen instantly with a 100 page document loaded into a field

          • 2. Re: Serialize

            This is what I want to do, it does not matter how long it takes. So i would loop the script? I could not get the original function to work, but I will try it again.

            • 3. Re: Serialize

              It took some testing and tinkering, but this script works:

              Set Variable [ $Size; Value:Length ( LoopingFindReplace::Word ) ]
              Set Selection [ LoopingFindReplace::TextField; Start Position: 0; End Position: 0 ]
                     Set Variable [ $I; Value:$I + 1 ]
                     Perform Find/Replace [ Find: LoopingFindReplace::Word; Search operation: Find Next; Search settings: Forward, Match whole words only;
                          Search across: Current record/request; Search within: Current field ] [ No dialog ]
                     Set Variable [ $Start; Value:Get ( ActiveSelectionStart ) ]
                     Exit Loop If [ IsEmpty ( $start ) ]
                     Set Field [ LoopingFindReplace::TextField; Left ( LoopingFindReplace::TextField ; $start + $size - 1 ) & " " & $I &
                           Right ( LoopingFindReplace::TextField ; Length ( LoopingFindReplace::TextField ) - ( $start + $size ) + 1 ) ]
                     Set Selection [ LoopingFindReplace::TextField; Start Position: $start + $size + Length ( $I ) + 1; End Position: 0 ]
              End Loop

              The key detail I had to work out is that Perform Find/Replace with the current field option requires that the cursor be in the field to be searched, but the step also exits the field each time it executes. Thus, the Set Selection step is required to put the cursor back into the field and in the correct location in order to continue searching out instances of the text entered into the LoopingFindReplace::Word field.

              • 4. Re: Serialize

                Well... You are definately a master at scripting. Once again, thank you for an awesome response. I wish I had your skills.

                Carl Jones
                Test Engineer