LOOP to copy and append

LOOP to copy and append

74
Advanced UserAdvanced User
74

    Oct 14, 2004#1

    Situation after running my initial script this is my output. Problem is there are more then one "Figure" associated with the <item><?hotspot color="blue" href=__!'#-##' >

    What I need to do is copy the "<item..." information and append it to all the figures below it till it reaches the next "<item", then repeat.

    I know this would be a loop, but how


    Loop
    Find regexp "<item><?hotspot color="blue" href=__!"
    select
    copy
    replace ">Figure.*"

    :?:

    SAMPLE TEXT:
    <item><?hotspot color="blue" href=__!'2-17.1A'
    >Figure 2-85. test<?/hotspot></item>

    <item><?hotspot color="blue" href=__!'2-17.1'
    >Figure 2-86. test<?/hotspot></item>

    <item><?hotspot color="blue" href=__!'2-17.3'
    >Figure 2-87. test<?/hotspot></item>
    >Figure 2-90. test<?/hotspot></item>

    <item><?hotspot color="blue" href=__!'2-17.4'
    >Figure 2-88. test<?/hotspot></item>

    <item><?hotspot color="blue" href=__!'2-18'
    >Figure 2-89. test<?/hotspot></item>

    <item><?hotspot color="blue" href=__!'2-18.1'
    >Figure 2-90. test<?/hotspot></item>
    >Figure 2-90. test<?/hotspot></item>

    <item><?hotspot color="blue" href=__!'2-18.2'
    >Figure 2-91. test<?/hotspot></item>

    <item><?hotspot color="blue" href=__!'2-19'
    >Figure 2-92. test<?/hotspot></item>
    >Figure 2-90. test<?/hotspot></item>

    OUTPUT DESIRED:
    <item><?hotspot color="blue" href=__!'2-17.1A'>Figure 2-85. test<?/hotspot></item>

    <item><?hotspot color="blue" href=__!'2-17.1'>Figure 2-86. test<?/hotspot></item>

    <item><?hotspot color="blue" href=__!'2-17.3'>Figure 2-87. test<?/hotspot></item>
    <item><?hotspot color="blue" href=__!'2-17.3'>Figure 2-90. test<?/hotspot></item>

    <item><?hotspot color="blue" href=__!'2-17.4'>Figure 2-88. test<?/hotspot></item>

    <item><?hotspot color="blue" href=__!'2-18'>Figure 2-89. test<?/hotspot></item>

    <item><?hotspot color="blue" href=__!'2-18.1'>Figure 2-90. test<?/hotspot></item>
    <item><?hotspot color="blue" href=__!'2-18.1'>Figure 2-90. test<?/hotspot></item>

    <item><?hotspot color="blue" href=__!'2-18.2'>Figure 2-91. test<?/hotspot></item>

    <item><?hotspot color="blue" href=__!'2-19'>Figure 2-92. test<?/hotspot></item>
    <item><?hotspot color="blue" href=__!'2-19'>Figure 2-90. test<?/hotspot></item>

    6,602547
    Grand MasterGrand Master
    6,602547

      Oct 15, 2004#2

      Try this macro, it works for your example:

      InsertMode
      ColumnModeOff
      HexOff
      UnixReOff
      Top
      Find RegExp "<item><^?hotspot color="blue" href=__!*$"
      IfNotFound
      ExitMacro
      EndIf
      StartSelect
      Cut
      Key DEL
      Loop
      IfCharIs ">"
      Paste
      Key HOME
      Key DOWN ARROW
      Else
      Find RegExp "<item><^?hotspot color="blue" href=__!*$"
      IfNotFound
      ExitMacro
      EndIf
      StartSelect
      Cut
      Key DEL
      EndIf
      EndLoop
      Best regards from an UC/UE/UES for Windows user from Austria

      74
      Advanced UserAdvanced User
      74

        Oct 15, 2004#3

        Still have the problem of Figure #'s left without an item tag.

        Results were:

        <item><?hotspot color="blue" href=__!'2-17.1A'>Figure 2-85. test<?/hotspot></item>

        <item><?hotspot color="blue" href=__!'2-17.1'>Figure 2-86. test<?/hotspot></item>

        <item><?hotspot color="blue" href=__!'2-17.3'>Figure 2-87. test<?/hotspot></item>

        :arrow: >Figure 2-90. test<?/hotspot></item>

        <item><?hotspot color="blue" href=__!'2-17.4'>Figure 2-88. test<?/hotspot></item>

        <item><?hotspot color="blue" href=__!'2-18'>Figure 2-89. test<?/hotspot></item>

        <item><?hotspot color="blue" href=__!'2-18.1'>Figure 2-90. test<?/hotspot></item>

        :arrow: >Figure 2-90. test<?/hotspot></item>

        <item><?hotspot color="blue" href=__!'2-18.2'>Figure 2-91. test<?/hotspot></item>


        :arrow: >Figure 2-92. test<?/hotspot></item>

        :arrow: >Figure 2-90. test<?/hotspot></item>


        Thank you for working on this with me. I'm still trying to figure this out. :lol: Max

          Oct 15, 2004#4

          this is kinda querky..I restarted my PC and ran the script again, the results were exactly what I wanted. But when I ran it on another test file nothing happened.

          Test File:
          <item><?hotspot color="blue" href='\ch2sec3.sgm!'2-17'

          <item><?hotspot color="blue" href='\ch2sec3.sgm!'2-17.1A'
          >Figure 2-85. Testing<?/hotspot></item>

          <item><?hotspot color="blue" href='\ch2sec3.sgm!'2-17.1'
          >Figure 2-86. Testing<?/hotspot></item>

          <item><?hotspot color="blue" href='\ch2sec3.sgm!'2-17.3'
          >Figure 2-87. Testing<?/hotspot></item>

          <item><?hotspot color="blue" href='\ch2sec3.sgm!'2-17.4'
          >Figure 2-88. Testing<?/hotspot></item>

          <item><?hotspot color="blue" href='\ch2sec3.sgm!'2-18'
          >Figure 2-89. Testing<?/hotspot></item>

          <item><?hotspot color="blue" href='\ch2sec3.sgm!'2-18.1'
          >Figure 2-90. Testing<?/hotspot></item>

          <item><?hotspot color="blue" href='\ch2sec3.sgm!'2-18.2'
          >Figure 2-91. Testing<?/hotspot></item>

          <item><?hotspot color="blue" href='\ch2sec3.sgm!'2-19'
          >Figure 2-92. Testing<?/hotspot></item>

          <item><?hotspot color="blue" href='\ch2sec3.sgm!'2-19.1'
          >Figure 2-93. Testing<?/hotspot></item>

          <item><?hotspot color="blue" href='\ch2sec3.sgm!'2-19.2'
          >Figure 2-94. Testing<?/hotspot></item>

          <item><?hotspot color="blue" href='\ch2sec3.sgm!'2-19.3'
          >Figure 2-95. Testing<?/hotspot></item>

          <item><?hotspot color="blue" href='\ch2sec3.sgm!'2-20'

          <item><?hotspot color="blue" href='\ch2sec3.sgm!'2-20.1A'
          >Figure 2-96. Testing<?/hotspot></item>

          <item><?hotspot color="blue" href='\ch2sec3.sgm!'2-21'

          <item><?hotspot color="blue" href='\ch2sec3.sgm!'2-22'

          <item><?hotspot color="blue" href='\ch2sec3.sgm!'2-22.1'

          <item><?hotspot color="blue" href='\ch2sec3.sgm!'2-22.2'

          <item><?hotspot color="blue" href='\ch2sec3.sgm!'2-22.3'

          <item><?hotspot color="blue" href='\ch2sec3.sgm!'2-22.4'

          <item><?hotspot color="blue" href='\ch2sec3.sgm!'2-24.2.1A'
          >Figure 2-97. Testing<?/hotspot></item>
          >Figure 2-98. Testing<?/hotspot></item>

          Thanks for the help. <smiles>Max

            Oct 15, 2004#5

            May be I'm looking at this the wrong way. If I had this string

            <item><?hotspot color="blue" href=__!'2-24.2.1A' >Figure 2-97. AN/TPS-59 (V)3<?/hotspot></item> >Figure 2-98. AN/TPS-63<?/hotspot></item>

            Is there a way to say

            If figure appears more than once, copy item and paste?

            6,602547
            Grand MasterGrand Master
            6,602547

              Oct 16, 2004#6

              That nothing happens on the second testfile is the reason, why I have written the first find outside the loop. So the macro exits without changing anything, if executed by mistake on a different file where the find string is not found.

              Update the macro by modifying the find expression and it will work on all your files:

              InsertMode
              ColumnModeOff
              HexOff
              UnixReOff
              Top
              Find RegExp "<item><^?hotspot color="blue" href=*$"
              IfNotFound
              ExitMacro
              EndIf
              StartSelect
              Cut
              Key DEL
              Loop
              IfCharIs ">"
              Paste
              Key HOME
              Key DOWN ARROW
              Else
              Find RegExp "<item><^?hotspot color="blue" href=*$"
              IfNotFound
              ExitMacro
              EndIf
              StartSelect
              Cut
              Key DEL
              EndIf
              EndLoop
              Best regards from an UC/UE/UES for Windows user from Austria

              74
              Advanced UserAdvanced User
              74

                Oct 18, 2004#7

                Thank you for your response.

                I tried looking at the input from a different stand point and realized there was something all the figures had in common when they needed to have the leading item information added...each figure consistently had </item> > Figure. So using this as my guide I created this script which has worked fabulously. Thank you for all your help! Max
                :D
                InsertMode
                ColumnModeOff
                HexOff
                UnixReOn
                Top
                Loop
                Find RegExp "^([<]item[>].*'.*')"
                IfNotFound
                ExitLoop
                EndIf
                Copy
                Key HOME
                Find RegExp "[<][/]item[>] [>]Figure.*.*"
                Replace All "</item>^p^c > Figure"