Jump to content

fileread/filereadline


Recommended Posts

hi when i have read a file i want to select/search to a word

b.v. when i get this when i read the file

hello=hello

test=test

autoit=autoit

c++=c++

i want to make that he select only the test:

so i want to select the secend word test

because when i read it something is there standing something different

is that a possebility with Select("test=******")

i wanne read the *****

how i can do this

Link to comment
Share on other sites

#include <file.au3>

Dim $aRecords

If Not _FileReadToArray("data.txt",$aRecords) Then
   MsgBox(4096,"Error", " Error reading TXT to Array     error:" & @error)
   Exit
EndIf

For $x = 1 to $aRecords[0]
    $data = StringSplit($aRecords[$x], '=')
    If Not @error Then
        If $data[1] = 'test' Then Msgbox(0,'Record test',$data[2])
    EndIf
Next

Link to comment
Share on other sites

My approach:

$fhandle=FileOpen("filename.txt",0)

Do
    $line=FileReadLine($fhandle)
    If @error=-1 Then ExitLoop
    If StringInStr($line,"test=") Then
        MsgBox(0,"Result",StringTrimLeft($line,StringLen("test=")))
    EndIf
Until False

:)

when i run it i get a loop that dont stop.. i'm the value is right of the test= and the fileopen...

Link to comment
Share on other sites

when i run it i get a loop that dont stop.. i'm the value is right of the test= and the fileopen...

Works for me with this text file:

hello=hello
test=test
autoit=autoit
c++=c++

Broken link? PM me and I'll send you the file!

Link to comment
Share on other sites

hi it works for me now only one problem but how do i set it in a $

i want not to show a msgbox but i just want to because in $value how do i do this?

$value=StringTrimLeft($line,StringLen("test="))

Instead of MsgBox()

:)

Broken link? PM me and I'll send you the file!

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...