Jump to content

Recommended Posts

Posted

Hello everybody, first of all i just want to thank this forum because im learning alot with it. But what i really need at the moment is some help with the function "FileReadLine", what i got to do in my script is get line 1 and "associate" or make it the $variable one.

What i need is something like this:

$var1 = ""
$var2 = ""
$var3 = ""

Local $file = FileOpen("test.txt", 0)
sleep(1000)
$var1 = FileReadLine("line one")
sleep(1000)
$var2 = FileReadLine("line two")
sleep(1000)
$var3 = FileReadLine("line three")
sleep(1000)

I know this code would not work, but its just a demonstration of what i need, i hope you guys can understand. Thank You.

  • Moderators
Posted

Hi, LucasSilva. I would suggest reading the file to an array. Then you can use the array as your variable. Something like this:

#include <Array.au3>
#include <File.au3>
;line 1 is Test
;line 2 is Test2
;line 3 is Test3
;line 4 is Test4
;line 5 is Test5

Local $aArray
 _FileReadToArray(@DesktopDir & "1.txt", $aArray)
MsgBox(0, "", $aArray[1])
MsgBox(0, "", $aArray[3])
MsgBox(0, "", $aArray[5])

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

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
  • Recently Browsing   0 members

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