Read from text file line number: Difference between revisions

From NSIS Wiki
Jump to navigationJump to search
m (Updated author and download links, and changed format of some pages.)
m (Updated author links.)
Line 1: Line 1:
{|align=right
|<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 38: Line 42:


-Stu (Afrow UK)
-Stu (Afrow UK)
Page author: [[User:Afrow UK|Afrow UK]]

Revision as of 03:02, 30 April 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)