Sign in to follow this  
Followers 0
ioliver

How To Read Text Ino My Script From A Text File

3 posts in this topic

Does anyone know if I can read text from a text file into my script as variables?

Ex. In VBScript I can do a readline, then use an array to seperate the text on the line.

Thanks for your help.

Ian


"Blessed be the name of the Lord" - Job 1:21Check out Search IMF

Share this post


Link to post
Share on other sites



There is an included UDF called _FileReadToArray( $sFilePath, ByRef $aArray )

It's listed in the Helpfile under "Library Function Reference"

script example:

#include <file.au3>

Dim $iRecs
_FileReadToArray( "test1.txt", $iRecs )
If @error=0 Then
   For $x = 1 to $iRecs[0] -1
      MsgBox(0,'record:' & $x,$iRecs[$x])
   Next
Else
  ; error
EndIf

You need to update the file.au3 in the include directory on the following line because it has an error currently:

record 203 should read:

$aArray = StringSplit( FileRead( $hFile, FileGetSize( $sFilePath ) ), @LF )


Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Thanks, that seems to work ok. But, after reading another post on the forum, I think INIREAD may be the way for me to go.

Thanks again,

Ian

Edited by ioliver

"Blessed be the name of the Lord" - Job 1:21Check out Search IMF

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0