Jump to content

How To Read Text Ino My Script From A Text File


Recommended Posts

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

Link to comment
Share on other sites

  • Developers

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 )

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

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

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...