LOOP to copy and append

Help with writing and playing macros

LOOP to copy and append

Postby mightymax » Thu Oct 14, 2004 10:46 am

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>
User avatar
mightymax
Basic User
Basic User
 
Posts: 30
Joined: Tue Jul 27, 2004 11:00 pm
Location: San Diego, CA

Re: LOOP to copy and append

Postby Mofi » Fri Oct 15, 2004 3:04 am

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
User avatar
Mofi
Grand Master
Grand Master
 
Posts: 4058
Joined: Thu Jul 29, 2004 11:00 pm
Location: Vienna

Re: LOOP to copy and append

Postby mightymax » Fri Oct 15, 2004 8:47 am

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
User avatar
mightymax
Basic User
Basic User
 
Posts: 30
Joined: Tue Jul 27, 2004 11:00 pm
Location: San Diego, CA

Re: LOOP to copy and append

Postby mightymax » Fri Oct 15, 2004 10:44 am

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
User avatar
mightymax
Basic User
Basic User
 
Posts: 30
Joined: Tue Jul 27, 2004 11:00 pm
Location: San Diego, CA

Re: LOOP to copy and append

Postby mightymax » Fri Oct 15, 2004 12:06 pm

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?
User avatar
mightymax
Basic User
Basic User
 
Posts: 30
Joined: Tue Jul 27, 2004 11:00 pm
Location: San Diego, CA

Re: LOOP to copy and append

Postby Mofi » Sat Oct 16, 2004 6:20 am

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
User avatar
Mofi
Grand Master
Grand Master
 
Posts: 4058
Joined: Thu Jul 29, 2004 11:00 pm
Location: Vienna

Re: LOOP to copy and append

Postby mightymax » Mon Oct 18, 2004 7:53 am

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"
User avatar
mightymax
Basic User
Basic User
 
Posts: 30
Joined: Tue Jul 27, 2004 11:00 pm
Location: San Diego, CA


Return to Macros