Sign in to follow this  
Followers 0
Krentenbol78

Read file

8 posts in this topic

Hi :)

I am working with a script and I wan't to read a textfile from a site.

For example:

http://mysite.com/textfile.txt

I wan't to read what's inside the file and display it in a messagebox.

I already searched bud couldn't find something usefull

(I don't want the text file embed but just what's in the text file stored in $file)

Thanks alot ! ^_^

Share this post


Link to post
Share on other sites



Something like:

InetGet("http://mysite.com/textfile.txt","targetfile")
$text=FileRead("targetfile")
MsgBox(0,"demo",$text)

:)


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

Thanks ^_^

But I have a problem if I modify the data in the file on the server it doesn't show in the programm :)

So if I modify the file to 1 it's should show a messagebox but it doesn't work for some reason.

Help please :)

;#NoTrayIcon

#include <GUIConstants.au3>




While 1
InetGet("http://krentenbol78.freehostia.com/file.txt","file.txt")
$result=FileRead("file")
Sleep(500)
FileDelete(@ScriptDir&"file.txt")
If $result=1 Then
MsgBox(0,"",$result)
EndIf
WEnd

Share this post


Link to post
Share on other sites

Yeah I already thought that was the problem but how do I do that.

You can see in the script that I tried to load the file and than delete the file but it doesn't work.

Do you have an idea ?

Thanks alot for all you're help :)

Share this post


Link to post
Share on other sites

Yeah I already thought that was the problem but how do I do that.

You can see in the script that I tried to load the file and than delete the file but it doesn't work.

Do you have an idea ?

Thanks alot for all you're help ^_^

Did you check the helpfile for the parameter ? :)

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

I think this is what Jos meant by reload, from InetGet help

InetGet ( "URL" [,"filename" [, reload [, background]]] )

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

I think there was also problem in error checking:

;#NoTrayIcon

#include <GUIConstants.au3>

While 1
$ok = InetGet("http://krentenbol78.freehostia.com/file.txt",@ScriptDir & "file.txt")
If $ok Then
$result=FileRead(@ScriptDir & "file")
$ok = Not @Error
Sleep(500)
FileDelete(@ScriptDir & "file.txt")
If $ok Then
MsgBox(0,"",$result)
EndIf
EndIf
Sleep(3000)
WEnd
Edited by Zedna

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