EmEditor (text editor) Forum Index
   Macro Samples
     Learning by doing: Loop through all lines
Register To Post

Flat Previous Topic | Next Topic
Poster Thread
Stefan
Posted on: 11/2/2011 3:54 am
Home away from home
Joined: 7/14/2008
From: Germany, EU
Posts: 262
Learning by doing: Loop through all lines
No useful script. Just an little lesion.
Loop virtually through all lines in file
The cursor will not move!
We access each line by its number only.

- - -

Best to learn is to do some lessons.
So i will show my steps creating an macro for others.

I am not saying that this is the best way to do it,
it is just an start.

If you have an better way to do it, or other
suggestions, just reply



////Loop virtually through all lines in file
////(Cursor will not move! 
//// We access each line by its number only.)

LinesInFile = document.GetLines();
LineToStart = 1;
alert ("Lines in file: " + LinesInFile);

////For Each Line in File Do:
for (var LINE = LineToStart; LINE <= LinesInFile; LINE++)
 {
  ////Get the lines content:
  str = document.GetLine(LINE);
  	
  ////===Example use, add here your own code======
       ////Show the content and ask to continue:
       bAnswer = confirm("Processing line " + LINE 
          + ".  Content:\n\n"
    	  + str + "\n\n\n\n"
	  + "Continue?" );
  	  
       ////What to do If you pressed cancel?:
       if (bAnswer == false){break;} 
        //use "break; to exit the "for" loop only
        //use "quit();" to cancel the whole script
  ////===END of Example use, =====================
 }

 alert("All done. Script quits.");
Flat Previous Topic | Next Topic


Subject Poster Date
 » Learning by doing: Loop through all lines Stefan 11/2/2011 3:54 am
     Re: Learning by doing: Loop through SELECTED lines Stefan 11/2/2011 12:45 pm
       Re: Learning by doing: Loop through SELECTED lines Stefan 11/2/2011 1:12 pm

Register To Post
 
English čeština Deutsch español français italiano 日本語 한국어 Русский 简体中文 繁體中文