Read from text file line number: 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 ==
This is a simple script that outputs whatever text is on the inputted line number.
This is a simple script that outputs whatever text is on the inputted line number.
Line 43: Line 41:
-Stu (Afrow UK)
-Stu (Afrow UK)


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

Latest revision as of 13:36, 24 June 2005

Author: Afrow UK (talk, contrib)


Description

This is a simple script that outputs whatever text is on the inputted line number.

Usage

Push 23 ;line number to read from
Push "$INSTDIR\file.txt" ;text file to read
 Call ReadFileLine
Pop $0 ;output string (read from file.txt)

The Script

Function ReadFileLine
Exch $0 ;file
Exch
Exch $1 ;line number
Push $2
Push $3
 
  FileOpen $2 $0 r
 StrCpy $3 0
 
Loop:
 IntOp $3 $3 + 1
  ClearErrors
  FileRead $2 $0
  IfErrors +2
 StrCmp $3 $1 0 loop
  FileClose $2
 
Pop $3
Pop $2
Pop $1
Exch $0
FunctionEnd

-Stu (Afrow UK)