Jump to content
Sign in to follow this  
yucatan

fileread/filereadline

Recommended Posts

yucatan

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

Share this post


Link to post
Share on other sites
Zedna

#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

Share this post


Link to post
Share on other sites
yucatan

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

Share this post


Link to post
Share on other sites
monoceres

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!

Share this post


Link to post
Share on other sites
yucatan

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?

Share this post


Link to post
Share on other sites
monoceres

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!

Share this post


Link to post
Share on other sites
yucatan

i'v already got already got it thx alot man (K)

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  

×