Welcome to the IDM Forum. This forum is meant as a user-to-user support mechanism where users can share knowledge and tips for all IDM software.
Since these forums are user-to-user based, IDM does not regularly read or reply to the posts in this forum. For problem reports, suggestions, or feature requests, you must email us directly. Our trained technical support staff answers most inquiries within 30 minutes.


NAME A11B4
DESCRIPTION ABC
TABELLE
Description ABC CBA HEADER1 s-out
A1174-3123 3 1.5 0.004455 3
A1174-4123 4 10 1.0866 4
A1174-5123 5 1.5 1.013459 5
COUNT
1174-3123 1 0
InsertMode
ColumnModeOff
HexOff
UnixReOff
Clipboard 9
// Mark the first file with a special string to know when to exit the loop.
Top
"ThIs Is ThE FiRsT FiLe!"
/*! The first file must be evaluated as last file because it propably does not
not contain the string of interest. The macro then could not close it to
avoid an endless loop, although it should be close. So better evaluate
the first file as last file. !*/
NextWindow
Loop
/*! Insert a line termination at end of the file if last line is not already terminated.
This is necessary when the column HEADER1 is the last column and so after ?.??? the
line termination follows. !*/
Bottom
IfColNum 1
Else
"
"
EndIf
Top
/*! Back at top of the file search for the header. If not found, ignore this file and
later close it, because it surely does not contain ?.??? in the requested column. !*/
Find MatchCase "HEADER1"
IfFound
/*! Header found! Copy everything from start of the current line
to beginning of HEADER1 into a new line at top of the file. !*/
Key Ctrl+LEFT ARROW
StartSelect
Key HOME
Copy
EndSelect
Top
Paste
"
"
Key UP ARROW
SelectLine
/*! Convert now this part of the header line into an UltraEdit style regular expression
with the required part to find ?.??? at end of the column or line, if the HEADER1
column is the last column. A header line like
Description ABC CBA HEADER1 ...
will be converted into
%*^t*^t*^t[0-9].[0-9][0-9][0-9][^t^r^n]
!*/
Find RegExp "[~^t^p]+^t"
Replace All SelectText "*^^^^t"
EndSelect
Top
"%"
Key END
"[0-9].[0-9][0-9][0-9][^t^r^n]"
// Copy this line into the user clipboard 9 and delete the line.
StartSelect
Key HOME
Cut
EndSelect
DeleteLine
// Search for the regular expression in the clipboard. This works only with UE style.
Find RegExp "^c"
// This useless looking code is necessary for the second Find/Replace in the Else branch.
IfNotFound
Top
EndIf
// This useless looking code is necessary for the second Find/Replace in the Else branch.
Else
Top
EndIf
IfSel
/*! The regular expression has found ?.??? in the correct column. So don't close
this file, but exit the loop when this file is the first/last file to evaluate.
But before always position the cursor to the string of interest. !*/
Top
Find MatchCase "ThIs Is ThE FiRsT FiLe!"
Replace ""
IfFound
Find RegExp "^c"
ExitLoop
EndIf
Find RegExp "^c"
NextWindow
Else
/*! No HEADER1 or no ?.??? in the column of HEADER1 - close the file. But first check
if this file is the first/last file to evaluate and exit the loop if this is true. !*/
Find MatchCase "ThIs Is ThE FiRsT FiLe!"
Replace ""
IfFound
CloseFile NoSave
ExitLoop
Else
CloseFile NoSave
EndIf
EndIf
EndLoop
ClearClipboard
Clipboard 0



HansFink wrote:- All open files already contain the required header (HEADER1), so after the data of HEADER1 is a tab (?.???^t)
HansFink wrote:- HEADER1 is never the first or last column
HansFink wrote:- The columns are not of fixed size
- The column number of HEADER1 can differ from file to file
HansFink wrote:- Column separator is one TAB between data, but can be several tabs between headers (headers can be missing, but not HEADER1)

NAME S_1.5 2-3x
SHORTNAME S_1
TRANS 0
TABELLE
tName A ABC D_IC
Description A Abc HEADER1 s-out
S_100 1010 3 26 0 0.018 4
S_125 1010 3.25 28 0 0.03 4
S_130 1010 3.3 32 0 0.0186 4
CONT
S_100 1010 0
S_125 1010 1
S_130 1010 1
NAME T_1.5 2-3x
SHORTNAME T_1
TRANS 0
TABELLE
typeName A ABC XYZ
Description A Abc Xyz HEADER1 s-out
T_1-4 4 5.7 17 0.2 4
T_1-5 5 5 18.5 0.2 5
T_1-1/4IN 6.35 6.35 21.175 0.2 6.35
CONT
T_1-4 1
T_1-5 1
T_1-1/4IN 1


