AutoHotkey Community

It is currently May 27th, 2012, 7:33 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 1 post ] 
Author Message
PostPosted: October 23rd, 2004, 7:21 pm 
Just in case you don't use an editor which provides line numbered print outs.

Code:
SetBatchLines -1

; The below section is for testing. A compiled version should work with arguments

1 = MyScript.ahk ; Inputfile
2 = MyScriptWithLineNumbers.txt    ; Outputfile (copy of Inputfile with line numbers)
3 = IOCF ; Save result within Inputfile/Outputfile/Clipboard/FileName
0 = 3

Loop, Read, %1% ; Get total (number of lines)
   {
   LC = %A_Index%
   }
StringLen, LH, LC ; Get length of total, to set the line number format

Loop, Read, %1%, %2%
   {
   If A_LoopReadLine =   ; If line is "empty" ...
      {
      LC -= 1 ; reduce total
      EL += 1 ; count the empty line
      }
   LN = %A_Index%
   SetFormat, float, 0%LH%.0 ; Set prefix based on length of total
   LN += 0.0
   Status = |Total:%LN%|Empty:%EL%|Written:%LC%| ; Create result
   If 0 >= 2 ; Create Outputfile (copy of Inputfile with line numbers)
      FileAppend, %LN% %A_LoopReadLine%`n
   }

IfInString, 3, I ; Append result to the Inputfile
   FileAppend, `; %Status%, %1%
IfInString, 3, O
   FileAppend, `; %Status%, %2% ; Append result to the Outputfile
IfInString, 3, C
   ClipBoard = %Status% ; Copy result to the ClipBoard
IfInString, 3, F
   FileCopy, %1%, %LN%.%EL%.%LC%_%1% ; Create a copy of InputFile with the result as part of its filename


Tweaking would be very much appreciated. Have Phun. Thx.

8)


Report this post
Top
  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: nothing and 10 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group