Read from text file line number: 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 39: Line 39:
-Stu (Afrow UK)
-Stu (Afrow UK)


Page author: Afrow UK
Page author: [[User:Afrow UK|Afrow UK]]

Revision as of 12:37, 23 April 2005

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)

Page author: Afrow UK