Using ultraedit script goto certain field in delimited data file

The following script is working in version 14.2, I am not sure previous version.


 

var delimiterStr="";

var findPosition=0;
var currentLine="";
var indexOfDel=0;
var colNum=0;
var gotoNextCharacterLocation=true;
  
delemiterStr = UltraEdit.getString("Please Enter a delimiter (^t is for TAB)",2);
if (delemiterStr=="^t")
{
delemiterStr = "\t"
}
findPosition = UltraEdit.getValue("Please Enter a field positon",2);

lineNum = UltraEdit.activeDocument.currentLineNum;
//store line in array entry, but without line termination
UltraEdit.activeDocument.key("HOME");
/* If configuration setting >Home Key Always Goto Column 1<
   is not enabled, the cursor could be not at start of the
   line, if the line starts with spaces or tabs. */
if (UltraEdit.activeDocument.isColNumGt(1)) {
  UltraEdit.activeDocument.key("HOME");
}


UltraEdit.activeDocument.startSelect();
UltraEdit.activeDocument.key("END");
currentLine= UltraEdit.activeDocument.selection;
UltraEdit.activeDocument.endSelect();
for ( colNum = 0; colNum < currentLine.length && gotoNextCharacterLocation==true; colNum++) {
if (currentLine.charAt(colNum) == delemiterStr) {
indexOfDel ++;
}
if (indexOfDel == findPosition) {
gotoNextCharacterLocation = false
UltraEdit.activeDocument.gotoLine(lineNum, colNum);  
}
}

转载于:https://www.cnblogs.com/yangbin990/archive/2009/04/02/1428427.html

你可能感兴趣的:(Using ultraedit script goto certain field in delimited data file)