Get number of lines in text file: Difference between revisions

From NSIS Wiki
Jump to navigationJump to search
m (Added category links.)
m (Adding new author and category links.)
 
Line 1: Line 1:
{|align=right
{{PageAuthor|Afrow UK}}
|<small>Author: [[{{ns:2}}:Afrow UK|Afrow UK]] ([[{{ns:3}}:Afrow UK|talk]], [[{{ns:-1}}:Contributions/Afrow UK|contrib]])</small>
 
|}
<br style="clear:both;">
== Description ==
== Description ==
I used this to show % complete for reading stats from a file.
I used this to show % complete for reading stats from a file.
Line 37: Line 35:
-Stu
-Stu


[[{{ns:14}}:Text Files Manipulation Functions]]
[[Category:Text Files Manipulation Functions]]

Latest revision as of 12:23, 24 June 2005

Author: Afrow UK (talk, contrib)


Description

I used this to show % complete for reading stats from a file.

Usage

Push [filename] ;text file
 Call LineCount
Pop $R0

$R0 = lines in file

The Function

Function LineCount
Exch $R0
Push $R1
Push $R2
 FileOpen $R0 $R0 r
loop:
 ClearErrors
 FileRead $R0 $R1
 IfErrors +3
  IntOp $R2 $R2 + 1
Goto loop
 FileClose $R0
 StrCpy $R0 $R2
Pop $R2
Pop $R1
Exch $R0
FunctionEnd

-Stu