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.



/* findValueFromSourceInTarget.js
Script reads through source file, and finds matching 3rd column in target
Then writes complete line from target to a another window.
ALL files should be in open tabs. If you do not want to hard code the file names,
then use the relational tab numbers for the files you have open */
var sourceFileTab = 3; /* seed with window tab# file is in */
var targetFileTab = 4; /* seed with window tab# file is in */
var colSep = String.fromCharCode(9); /* TAB character */
var LF = String.fromCharCode(13); /* LineFeed character */
UltraEdit.unixReOn(); /* designate regexp syntax style */
if( (sourceFileTab!=-1) && (targetFileTab!=-1) ) /* Validate that both source & target file are open */
findValueFromSourceFileInTargetFile();
/* Function to get 3rd col from source file and find in 3rd col in target file and write to next tab */
function findValueFromSourceFileInTargetFile() {
var sourceFile = UltraEdit.document[sourceFileTab];
var targetFile = UltraEdit.document[targetFileTab];
sourceFile.findReplace.regExp = true;
targetFile.findReplace.regExp = true;
var sourceFind = "^[A-Z]+\t[\"0-9]+\t[\"0-9]+\t";
sourceFile.top();
while ( (sourceFile.findReplace.find(sourceFind)) && ! sourceFile.isEof() ) {
var sourceHit = sourceFile.selection; /* seed var with value found */
UltraEdit.activeDocument.write(sourceHit.concat(String.fromCharCode(13)));
var cols = sourceHit.split(colSep);
UltraEdit.activeDocument.write(cols[2].concat(String.fromCharCode(13)));
// var targetFind = "^[A-Z]+\t[\"0-9]+\t"+cols[2]; /* search key from sourcefile, for example: *TAB*TAB"191909"TAB */
var targetFind = "^[A-Z]+\t[\"0-9]+\t"; /* search key from sourcefile, for example: *TAB*TAB"191909"TAB */
// UltraEdit.activeDocument.write(targetFind.concat(String.fromCharCode(13))); /* write search key to tab for debugging */
if ( targetFile.findReplace.find(targetFind) ) {
var targetHit = targetFile.selectLine;
UltraEdit.activeDocument.write(targetHit); /* write found line to next tab */
}
else {
UltraEdit.activeDocument.write("Not found in Target!!!!"); /* write found line to next tab */
}
}
/* Reposition at the top */
sourceFile.top();
targetFile.top();
}UPDATE "21090" "630188" "GFA CORPORATION" UPDATE "21090" "630188" "GFA CORPORATION" UPDATE "21090" "630188"
"630188"
Not found in Target!!!!
var sourceFind = "^[A-Z]+\t[\"0-9]+\t[\"0-9]+\t"; var sourceFind = "^[A-Z]+\\t[\"0-9]+\\t[\"0-9]+\\t"; var targetHit = targetFile.selectLine;
UltraEdit.activeDocument.write(targetHit); /* write found line to next tab */ targetFile.selectLine();
var targetHit = targetFile.selection;
UltraEdit.activeDocument.write(targetHit); /* write found line to next tab */
/* findValueFromSourceInTarget.js
Script reads through source file, and finds matching 3rd column in target
Then writes complete line from target to a another window.
ALL files should be in open tabs. If you do not want to hard code the file names,
then use the relational tab numbers for the files you have open */
var sourceFileTab = 3; /* seed with window tab# file is in */
var targetFileTab = 4; /* seed with window tab# file is in */
var colSep = String.fromCharCode(9); /* TAB character */
var LF = String.fromCharCode(13); /* LineFeed character */
UltraEdit.unixReOn(); /* designate regexp syntax style */
if( (sourceFileTab!=-1) && (targetFileTab!=-1) ) /* Validate that both source & target file are open */
findValueFromSourceFileInTargetFile();
/* Function to get 3rd col from source file and find in 3rd col in target file and write to next tab */
function findValueFromSourceFileInTargetFile() {
var sourceFile = UltraEdit.document[sourceFileTab];
var targetFile = UltraEdit.document[targetFileTab];
sourceFile.findReplace.regExp = true;
targetFile.findReplace.regExp = true;
var sourceFind = "^[A-Z]+\\t[\"0-9]+\\t[\"0-9]+\\t";
sourceFile.top();
while ( (sourceFile.findReplace.find(sourceFind)) && ! sourceFile.isEof() ) {
var sourceHit = sourceFile.selection; /* seed var with value found */
UltraEdit.activeDocument.write(sourceHit.concat(LF));
var cols = sourceHit.split(colSep);
UltraEdit.activeDocument.write(cols[2].concat(LF));
var targetFind = "^[A-Z]+\\t[\"0-9]+\\t"+cols[2]+"\\t"; /* search key from sourcefile, for example: *TAB*TAB"191909"TAB */
if ( targetFile.findReplace.find(targetFind) ) {
targetFile.selectLine();
var targetHit = targetFile.selection;
UltraEdit.activeDocument.write(targetHit); /* write found line to next tab */
} else {
UltraEdit.activeDocument.write("Not found in Target!!!!"); /* write found line to next tab */
}
}
/* Reposition at the top */
sourceFile.top();
targetFile.top();
}


var targetFind = "^[A-Z]+\\t";
// var targetFind = "^[A-Z]+\\t[\"0-9]+\\t"+cols[2]+"\\t"; /* search key from sourcefile, for example: *TAB*TAB"191909"TAB */
UltraEdit.activeDocument.write(targetFind.concat(LF));
if ( targetFile.findReplace.find(targetFind) ) {UPDATE "21090" "630188"
"630188"
^[A-Z]+\t
Not found in Target!!!!UPDATE "21090" "630188" "GFA CORPORATION" 
targetFile.top();
if ( targetFile.findReplace.find(targetFind) ) {
var sourceFileTab = 3; /* seed with window tab# file is in */
var targetFileTab = 4; /* seed with window tab# file is in */
var sourceFileTab = 2; /* seed with window tab# file is in */
var targetFileTab = 3; /* seed with window tab# file is in */


/* findValueFromSourceInTarget.js
Script reads through source file, and finds matching 3rd column in target
Then writes complete line from target to a another window.
ALL files should be in open tabs. If you do not want to hard code the file names,
then use the relational tab numbers for the files you have open */
var sourceFileTab = 2; /* seed with window tab# file is in */
var targetFileTab = 3; /* seed with window tab# file is in */
var outputFoundTab = 4; /* seed with window tab# for writing found data */
var debugTab = 5; /* seed with window tab# for writing debug data */
var colSep = String.fromCharCode(9); /* TAB character */
var LF = String.fromCharCode(13); /* LineFeed character */
UltraEdit.unixReOn(); /* designate regexp syntax style */
// Validate that UES windows to use are open are open */
if( (sourceFileTab!=-1) && (targetFileTab!=-1) && (outputFoundTab!=-1) && (debugTab!=-1) )
findValueFromSourceFileInTargetFile();
/* Function to get 3rd col from source file and find in 3rd col in target file and
write complete line it was found on to output tab */
function findValueFromSourceFileInTargetFile() {
var sourceFile = UltraEdit.document[sourceFileTab];
var targetFile = UltraEdit.document[targetFileTab];
var outputFile = UltraEdit.document[outputFoundTab];
var debugFile = UltraEdit.document[debugTab];
sourceFile.findReplace.regExp = true;
targetFile.findReplace.regExp = true;
var sourceFind = "^[A-Z]+\\t[\"0-9]+\\t[\"0-9]+\\t";
sourceFile.top();
while ( (sourceFile.findReplace.find(sourceFind)) && ! sourceFile.isEof() ) {
var sourceHit = sourceFile.selection; /* value found in sourcefile */
debugFile.write(sourceHit.concat(LF)); /* write info to debug tab */
var cols = sourceHit.split(colSep); /* extract delimited cols into array elements */
debugFile.write(cols[2].concat(LF)); /* write info to debug tab */
/* search key from sourcefile- .start @beginning of each row
.then match any Uppercase letters until a TAB
.then match TAB
.then match double quotes and digits 0-9 until a TAB
.then match value extracted from sourcefile ex. "191909"
.then match TAB */
var targetFind = "^[A-Z]+\\t[\"0-9]+\\t"+cols[2]+"\\t";
debugFile.write(targetFind.concat(LF)); /* write info to debug tab */
debugFile.write(LF);
targetFile.top();
if ( targetFile.findReplace.find(targetFind) ) {
targetFile.selectLine();
var targetHit = targetFile.selection;
outputFile.bottom();
outputFile.write(targetHit); /* write complete row that info was found on to output tab */
} else {
debugFile.write("Not found in Target!!!!"); /* write error to debug tab */
}
}
}UPDATE "99883" "191909" "SHELEY ENTERPRISES"
UPDATE "99885" "651429" "COLD WATER INDUSTRIES"
UPDATE "21090" "434957" "ADVANCED MAILING SVC"
UPDATE "21090" "428918" "EINS SERVICES"
UPDATE "21090" "650297" "GOLD STAR PEST CONTROL INC"UPDATE "99883" "191909" "SHELEY ENTERPRISES"
UPDATE"99885" "651429" "COLD WATER INDUSTRIES"
UPDATE"21090" "434957" "ADVANCED MAILING SVC"
UPDATE"21090" "428918" "EINS SERVICES"
UPDATE"21090" "650297" "GOLD STAR PEST CONTROL INC"
spaceBAR wrote:Would it run faster if I did it in a UE macro?

