Jump to content

Read txt in real time


Recommended Posts

I understand this :

$file = FileOpen("test.txt", 0)
; Check if file opened for reading OK
If $file = -1 Then
    MsgBox(0, "Error", "Unable to open file.")
    Exit
EndIf

; Read in 1 character at a time until the EOF is reached
While 1
    $chars = FileRead($file, 1)
    If @error = -1 Then ExitLoop
    MsgBox(0, "Char read:", $chars)
Wend
FileClose($file)

But... I dont get the way to open a Windows and display the text inside it.

Link to comment
Share on other sites

Mmm. this put the text on the GUI but show only one line

It does'nt make a return (CR)...

#include <GUIConstants.au3>

$file = FileOpen("test.txt", 0)

; Check if file opened for reading OK

If $file = -1 Then

MsgBox(0, "Error", "Unable to open file.")

Exit

EndIf

GUICreate("Test", 600, 300)

GUISetState(@SW_SHOW)

While 1

$line = FileReadLine($file)

GUICtrlCreateEdit ($line , 10, 10 , 590 , 290 )

sleep(2000)

If @error = -1 Then ExitLoop

WEnd

Edited by Tentaal
Link to comment
Share on other sites

Mmm. this put the text on the GUI but show only one line

It does'nt make a return (CR)...

Try this (not tested):

#include <GUIConstants.au3>

$file = FileOpen("test.txt", 0)

; Check if file opened for reading OK
If $file = -1 Then
    MsgBox(0, "Error", "Unable to open file.")
    Exit
EndIf

GUICreate("Test", 600, 300)
$edit = GUICtrlCreateEdit ($line , 10, 10 , 590 , 290 )
GUISetState(@SW_SHOW)

While 1
    $data = FileRead($file)
    GUICtrlSetData ($edit, $data)
    If @error = -1 Then ExitLoop
    sleep(2000)
WEnd

FileClose($file)

;finally show whole result
While 1
    $msg = GUIGetMsg()
    
    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
Wend
Link to comment
Share on other sites

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