Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #10995
    yak
    Member
    var strAnswer = prompt( "find waht ?", "w+" );  var count=0;  while ( document.selection.Find( strAnswer, eeFindNext | eeFindReplaceRegExp) ) {   count++;  }   OutputBar.Clear();  OutputBar.writeln( "find count: "+count );  OutputBar.Visible = true;  OutputBar.SetFocus();   

    serach document by regex which you input,find and print match counts

    #17282
    Stefan
    Participant

    Good example of utilizing “OutputBar”, thanks.

    If you are interested, you can modify your script with some details like shown here:

    
    // do not update the screen during our work:
    	Redraw = false;
    	
    // get and store current cursor position:
    	yPos = document.selection.GetActivePointY( eePosLogical );
    	xPos = document.selection.GetActivePointX( eePosLogical );
    
    // ask the user:
    	var strAnswer = prompt( "find what ?", "\\w+" );  
    
    // do the work; search for occurrences:
    	var count=0; 
    	while ( document.selection.Find( strAnswer, eeFindNext | eeFindReplaceRegExp) )
    	 {   count++;  }   
    
    // provide the result to the output bar:
    	OutputBar.Clear(); 
    	OutputBar.writeln( "find count for \"" + strAnswer + '\" after column ' 
    	                                 + xPos + ' of  row ' + yPos + ': ' + count );
    	OutputBar.Visible = true; OutputBar.SetFocus();   
    
    // erase search highlighting:
    	document.HighlightFind = false;
    
    // go back to origin cursor position:
    	document.selection.SetActivePoint( eePosLogical, xPos, yPos, false );
    

    Keep up! ;-)

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.