LineSum: Difference between revisions

From NSIS Wiki
Jump to navigationJump to search
m (Wikipedia python library)
 
m (Updated author and download links, and changed format of some pages.)
Line 66: Line 66:
</highlight-nsis>
</highlight-nsis>


 
Page author: [[User:Instructor|Instructor]]
Page author: Instructor

Revision as of 12:44, 23 April 2005

Links

Latest version of headers "nsh.zip"
http://forums.winamp.com/showthread.php?s=&threadid=203228&goto=lastpost

If function used without header then put function in script before call it

The Function

/*
____________________________________________________________________________
 
                            LineSum v1.0
____________________________________________________________________________
 
2004 Shengalts Aleksander (Shengalts@mail.ru)
 
Thanks Afrow UK (Based on his idea of Function "LineCount" 2003-08-17)
 
 
Get sum of lines in text file.
 
 
Syntax:
Push "file"    ; Input file
Call LineSum   ; Call function
Pop $var       ; Sum of lines
 
 
Note:
-Error flag if input file isn't exists
 
 
Example:
Section
	Push "C:\a.log"
	Call LineSum
	Pop $R0    ; $R0 now contain: "54"
SectionEnd*/
 
 
Function LineSum
	Exch $0
	Push $1
	Push $2
	ClearErrors
 
	IfFileExists $0 0 error
	StrCpy $2 0
	FileOpen $0 $0 r
	FileRead $0 $1
	IfErrors +3
	IntOp $2 $2 + 1
	Goto -3
	FileClose $0
	StrCpy $0 $2
	goto end
 
	error:
	SetErrors
	StrCpy $0 ''
 
	end:
	Pop $2
	Pop $1
	Exch $0
FunctionEnd

Page author: Instructor