AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

GetLineNumberedScript for printouts

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions
View previous topic :: View next topic  
Author Message
BoBo
Guest





PostPosted: Sat Oct 23, 2004 7:21 pm    Post subject: GetLineNumberedScript for printouts Reply with quote

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.

Cool
Back to top
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group