by Mofi » Sun Sep 11, 2005 11:20 am
The path specification in the SaveAs command is correct (only one '\').
I now tested it and replaced the $ at end of the regular expression search by a \p to avoid that all found strings are stored in a single line. And I removed the square brackets around the first number, because they are simply not necessary.
Activate also the macro property Continue if a Find with Replace not found for your macro.
What you also have forgotten is the CloseFile command. After first search loop and SaveAs the next search loop was running at the already saved new file and so nothing was found.
Last I also added with SelectAll and IfSel commands a detection, if the new file really contains anything. If not the new file is closed without saving it to avoid creation of files without content (0 byte file size).
Here is the modified macro:
InsertMode
ColumnModeOff
HexOff
UnixReOn
Clipboard 9
Top
ClearClipboard
Loop
Find RegExp "^1\.[0-9]*.*\p"
IfFound
CopyAppend
Else
ExitLoop
EndIf
EndLoop
NewFile
Paste
SelectAll
IfSel
SaveAs "c:\001.txt"
EndIf
CloseFile NoSave
... copy green block also for numbers 2 to 9 here ...
Top
ClearClipboard
Clipboard 0
Although ^c could be used for Find and SaveAs, this would unnecessarily complicate your macro for your example. Using ^c would need a modification of the source file to temporary remove all already found lines by using CutAppend instead of CopyAppend. Also it would be necessary to have a nested loop, which is not possible in UltraEdit's macro language, so the inner loop must be put in an extra macro. I know how to write this 2 macros, but it is not necessary to do that until the number at starting of each line before the point is not increasing.