I know how to send the current file name/path to an advanced tool, but is there a way of sending the file name/path of ALL open files?
No, not directly! Does your tool support a list file?
Many tools like packers or UltraEdit or UEStudio supports a list file, which contains per line the full path and name of a file. It's possible to generate such a list file with the names of all open files with a macro and then run the tool from within the macro with the list file.
If your tool does not support a list file, it is possible to use a macro to generate a "file1 file2 file3 file4" string (all files with full path), select this string and run the tool. The tool must have specified as parameter %sel%.
Note: The second method has 1 disadvantage. The number of characters on a command line is limited by Windows (1024 characters, I think). So it will fail if you have many files with long path/name open.
Tell us if your tool supports a list file or if method 2 must be used. Also let us know, which string can be found in all open files at least once but not too often because a Find In Files must be used to get the file names of all open files - see Return just list of files.
Many tools like packers or UltraEdit or UEStudio supports a list file, which contains per line the full path and name of a file. It's possible to generate such a list file with the names of all open files with a macro and then run the tool from within the macro with the list file.
If your tool does not support a list file, it is possible to use a macro to generate a "file1 file2 file3 file4" string (all files with full path), select this string and run the tool. The tool must have specified as parameter %sel%.
Note: The second method has 1 disadvantage. The number of characters on a command line is limited by Windows (1024 characters, I think). So it will fail if you have many files with long path/name open.
Tell us if your tool supports a list file or if method 2 must be used. Also let us know, which string can be found in all open files at least once but not too often because a Find In Files must be used to get the file names of all open files - see Return just list of files.
Best regards from an UC/UE/UES for Windows user from Austria
I can re-program the tool to read a list file if I need to. It takes a basic command line variable of a file name now, but it won't be hard to parse the file names from a list file instead.
Basically what the tool does is merge a number of NCF files for a specific part number to be sent to a another program (which I also wrote), that will use RS232 to transfer the merged files to a CNC machine.
The NCF files will generally have the same basic file name, i.e.
Dir\680-006195-1 REV 1-1.NCF
Dir\680-006195-1 REV 1-2.NCF
Dir\680-006195-1 REV 1-3.NCF
Although at times they will be different, i.e.
Dir\680-006195-1 REV 1-1.NCF
Dir\680-006195-1 REV 1-2.NCF
Dir\680-006195-1 REV 1-3.NCF
Different Dir\D896982-1 REV 1-1.NCF
Different Dir\D896982-1 REV 1-2.NCF
They will all contain the same basic info at the beginning of each file, with the 3rd line of every file containing the file's name, i.e.
The group of file names that I will be merging will almost always be different every time I use the tool.
Thanks for the help.
Basically what the tool does is merge a number of NCF files for a specific part number to be sent to a another program (which I also wrote), that will use RS232 to transfer the merged files to a CNC machine.
The NCF files will generally have the same basic file name, i.e.
Dir\680-006195-1 REV 1-1.NCF
Dir\680-006195-1 REV 1-2.NCF
Dir\680-006195-1 REV 1-3.NCF
Although at times they will be different, i.e.
Dir\680-006195-1 REV 1-1.NCF
Dir\680-006195-1 REV 1-2.NCF
Dir\680-006195-1 REV 1-3.NCF
Different Dir\D896982-1 REV 1-1.NCF
Different Dir\D896982-1 REV 1-2.NCF
They will all contain the same basic info at the beginning of each file, with the 3rd line of every file containing the file's name, i.e.
Code: Select all
%
O0001
(680-006195-1 REV 1-1.NCF)
(JAN 23, 2006 12:25)
<snip>
Code: Select all
%
O0002
(680-006195-1 REV 1-2.NCF)
(JAN 23, 2006 12:25)
<snip>
Code: Select all
%
O0003
(680-006195-1 REV 1-3.NCF)
(JAN 23, 2006 12:25)
<snip>
Thanks for the help.
The first macro will generate a list file with the full names of all open files which contain a line starting with a (, followed by any characters and has the string .NCF) (line 3 of your NCF files). It should be found only once in every open file. If there are more occurences of this string found in a file, the Sort command will remove duplicates.
Modify the path and name of the list file at the end of the macro to your needs and add the macro command to run your tool at the end of the macro.
The Loop is a workaround for a bug I found in v11.20a. UltraEdit continues the macro execution after FindInFiles before the log file with the search results is generated and has the focus. The loop searches through the open files for the log file with the search results.
InsertMode
ColumnModeOff
HexOff
UnixReOff
FindInFiles RegExp Log OpenFiles "" "" "%(*.NCF)"
Loop
Find RegExp Up "%Search complete, found *^p"
IfFound
Delete
ExitLoop
Else
NextWindow
EndIf
EndLoop
Top
Find "----------------------------------------^p"
Replace All ""
Find RegExp "%Find *^p"
Replace All ""
Find RegExp "%Found *^p"
Replace All ""
Find RegExp "/[0-9]+:*$"
Replace All ""
SortAsc IgnoreCase RemoveDup 1 -1 0 0 0 0 0 0
SaveAs "F:\Temp\NCF_List.txt"
UnixReOn
Here is a second macro which generates a single line with full names of all open files (with surrounding "") and selects it, so you can run your tool with all open files specified on the command line and the tool parameter %sel%.
InsertMode
ColumnModeOff
HexOff
UnixReOff
FindInFiles RegExp Log OpenFiles "" "" "%(*.NCF)"
Loop
Find RegExp Up "%Search complete, found *^p"
IfFound
Delete
ExitLoop
Else
NextWindow
EndIf
EndLoop
Top
Find "----------------------------------------^p"
Replace All ""
Find RegExp "%Find *^p"
Replace All ""
Find RegExp "%Found *^p"
Replace All ""
Find RegExp "/[0-9]+:*$"
Replace All ""
SortAsc IgnoreCase RemoveDup 1 -1 0 0 0 0 0 0
Find RegExp "%^(*^)^p"
Replace All ""^1" "
StartSelect
Key END
Key LEFT ARROW
EndSelect
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.
You have to enable the macro property Continue if a Find with Replace not found for both macros.
Modify the path and name of the list file at the end of the macro to your needs and add the macro command to run your tool at the end of the macro.
The Loop is a workaround for a bug I found in v11.20a. UltraEdit continues the macro execution after FindInFiles before the log file with the search results is generated and has the focus. The loop searches through the open files for the log file with the search results.
InsertMode
ColumnModeOff
HexOff
UnixReOff
FindInFiles RegExp Log OpenFiles "" "" "%(*.NCF)"
Loop
Find RegExp Up "%Search complete, found *^p"
IfFound
Delete
ExitLoop
Else
NextWindow
EndIf
EndLoop
Top
Find "----------------------------------------^p"
Replace All ""
Find RegExp "%Find *^p"
Replace All ""
Find RegExp "%Found *^p"
Replace All ""
Find RegExp "/[0-9]+:*$"
Replace All ""
SortAsc IgnoreCase RemoveDup 1 -1 0 0 0 0 0 0
SaveAs "F:\Temp\NCF_List.txt"
UnixReOn
Here is a second macro which generates a single line with full names of all open files (with surrounding "") and selects it, so you can run your tool with all open files specified on the command line and the tool parameter %sel%.
InsertMode
ColumnModeOff
HexOff
UnixReOff
FindInFiles RegExp Log OpenFiles "" "" "%(*.NCF)"
Loop
Find RegExp Up "%Search complete, found *^p"
IfFound
Delete
ExitLoop
Else
NextWindow
EndIf
EndLoop
Top
Find "----------------------------------------^p"
Replace All ""
Find RegExp "%Find *^p"
Replace All ""
Find RegExp "%Found *^p"
Replace All ""
Find RegExp "/[0-9]+:*$"
Replace All ""
SortAsc IgnoreCase RemoveDup 1 -1 0 0 0 0 0 0
Find RegExp "%^(*^)^p"
Replace All ""^1" "
StartSelect
Key END
Key LEFT ARROW
EndSelect
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.
You have to enable the macro property Continue if a Find with Replace not found for both macros.
Best regards from an UC/UE/UES for Windows user from Austria
The second macro will work great with a small bit of tweaking with the %sel% function. I don't think I'll need to adjust the program's command line interpreter either.
Thanks Much!
Thanks Much!
Worked out well for the most part. The only thing that's bad (and it's something I could live with if I had to) is that it seems to be stuck in a do-loop or is waiting until I exit the program called in the tool. (Shows the cancel dialog until exiting)
Thanks again!
Thanks again!
Yes, that's normal. The tools are designed for a fast and short execution and then UltraEdit get's back the focus with or without the captured output from the tool. The macro waits for the tool exit before it continues to give the users the capability to modify the result of the tool - paste clipboard content from the tool or opens a file generated by the tool. It's also possible that the output of the tool is captured and replaces the current selection - see Advanced options in the tool configuration.Rekd wrote:... that it seems to be stuck in a do-loop or is waiting until I exit the program called in the tool. (Shows the cancel dialog until exiting)
So you have to press the Cancel button or the ESC key when your tool is started or you remove the tool macro command from the macro and always run first the macro (with a hotkey) and then your tool (also with a hotkey).
Best regards from an UC/UE/UES for Windows user from Austria
Makes good sense. I had a feeling it was along those lines. Perhaps an idea for future versions would be a way of doing some sort of 'process and procede' function.
The more I use it, the more I am realizing just how powerful these macros are. It's more like a scripting language than a macro function.
The more I use it, the more I am realizing just how powerful these macros are. It's more like a scripting language than a macro function.
Do you know what command is sent back to UE after the tool exits? Perhaps I could code that into the tool.
No, I don't know. I'm not a Windows programmer so I don't know how this is handled by Windows. Ask IDM support by email. The developers of IDM can tell you surely how the exit of the tool is detected by UltraEdit.
Best regards from an UC/UE/UES for Windows user from Austria