Programming 笔记

工作中遇到的问题就记载这里

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::

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);  
}
}

posted on 2009-04-02 19:29  IT 笔记  阅读(515)  评论(1编辑  收藏  举报