I think, nobody has understand what you want. Could you please extend your example with a bit more information?
What is your search string? Is the block only a single line where only a simple regular expression is needed or a real block with multiple lines? Do you want each block found copied into a new file or all blocks with that search string copied together (with CopyAppend) to a new file? Should the macro only split the source file blockwise to new files or do you want a block extraction macro?
Best regards from an UC/UE/UES for Windows user from Austria
Block of text has about 500 lines and starting with string "H046A112020000043728QZIS_U_BI_BILL_1 PRINTER JZVW01RP" and ending with string "CRDI-CONTROL %%LINES-END ZET_TYP_PATA TEXT ST SK".
In each block is only one line (unique) DARCH-SAP_DOC_ID with number of block.
In file is about 5000 block.
I have list of numbers of blocks (about 200), and I want to have each block of text from this list in separate file.
I use command "Find (ALT F3)" to find number of block - I jump "in the midle" of block (to line DARCH-SAP_DOC_ID ...).
I need the macro, wich select complete block of text and copy to new file.
Thank you very much! Second version works very well.
But would be perfect, when macro could read from list of numbers of blocks (second text file in the same directory), find relevant block and do it all for every number of list. Every separate file should by saved in same directory with the name "number.txt".
To extend the macro to do everything is no real problem. I just need the information, how the numbers are formated in the second file. 1 number per line or the numbers separated by space or an other character?
I assume, that there is 1 number per line and nothing else is in a line. You should only have open 2 files: The first file is your large file with the blocks. The second files contains the numbers. The second file has the focus.
Then run this macro with macro property Continue if a Find with Replace not found enabled. If a number is not found in the first file, this number is marked with "Not found ->" in the file with the list of numbers.
Note: First copy this macro to a normal edit window and use Trim Trailing Spaces to remove the spaces at end of the line caused by HTML format. Then select the code again and copy it to the edit macro dialog. This is important because of the 2
"
"
sequences where no space should be at end of first ".
InsertMode
ColumnModeOff
HexOff
Bottom UnixReOff
IfColNum 1
Else
"
"
EndIf
Top
TrimTrailingSpaces
Loop
IfEof
ExitLoop
EndIf
Clipboard 8
SelectWord
IfSel
Copy
EndSelect
Key HOME
NextWindow
Top
Find MatchCase RegExp "DARCH-SAP_DOC_ID 0++^c"
IfFound
Clipboard 9
Find Up "H046A112020000043728QZIS_U_BI_BILL_1 PRINTER JZVW01RP"
IfNotFound
Top
Else
EndSelect
Key HOME
EndIf
StartSelect
Find Select "CRDI-CONTROL %%LINES-END ZET_TYP_PATA TEXT ST SK"
IfSel
Key END
Else
SelectToBottom
EndIf
Copy
EndSelect
NewFile
Clipboard 8
Paste
".txt"
SelectToTop
Cut
Clipboard 9
Paste
"
"
Clipboard 8
SaveAs "^c"
CloseFile NoSave
PreviousWindow
Else
PreviousWindow
"Not found -> "
EndIf
EndIf
EndSelect
Key HOME
Key DOWN ARROW
EndLoop
Clipboard 8
ClearClipboard
Clipboard 9
ClearClipboard
Clipboard 0 UnixReOn
Remove the last red command, if you use regular expression in UltraEdit style by default instead of Unix style.
For UltraEdit v11.10c and lower see Advanced - Configuration - Find - Unix style Regular Expressions.
For UltraEdit v11.20 and higher see Advanced - Configuration - Searching - Unix style Regular Expressions.
Macro commands UnixReOn/UnixReOff modifies this setting.
Best regards from an UC/UE/UES for Windows user from Austria
I have two files - big one "RDI.txt" and second one "list_rdi.txt". In list_rdi.txt is list of numbers - 1 number per line.
I opened olny these two files and second file has the focus.
I run this macro with macro property "Continue if a Find with Replace not found enabled".
All numbers from list_rdi.txt are RDI.txt.
But when I run macro, all numbers in list_rdi.txt are marked with "Not found ->" and nothing else...
What is the problem?
I have modified the search string in my macro code now to a regular expression string where leading 0s are allowed before the DOC_ID number from the list file. See green and red highlighted parts and the new last paragraph after the macro code at my previous post.
Best regards from an UC/UE/UES for Windows user from Austria