Sign in to follow this  
Followers 0
Stuempi

MsgBox with FileReadLine

6 posts in this topic

Hi there,

I want to make a MsgBox listing all the lines of a txt-file.

Now with the following code I get a msgbox for each line I got in the file... is there any way to let me show a list of all the lines in ONE msgbox?

$file = FileOpen("delete.txt", 0)
        While 1
            $delete_read = FileReadLine($file)
            If @error = -1 Then ExitLoop
            MsgBox("", "test", $delete_read)
        Wend
        FileClose($file)

Share this post


Link to post
Share on other sites



If you want to read it line-by-line, then you'll need to combine the lines.

This way will read the entire file at once:

MsgBox(0, "test", FileRead("delete.txt"))

[font="Tahoma"]"Tougher than the toughies and smarter than the smarties"[/font]

Share this post


Link to post
Share on other sites

Try something with:

$File = FileOpen("delete.txt", 0)
$Split = StringSplit(FileRead($File), Chr(10))

For $i = 1 To $Split[0]
    $Line = FileReadLine($File, $i)
    MsgBox(0, "", $Line)
Next

FileClose($File)

Didnt test it!

AlmarM


Minesweeper

A minesweeper game created in autoit, source available.

_Mouse_UDF

An UDF for registering functions to mouse events, made in pure autoit.

2D Hitbox Editor

A 2D hitbox editor for quick creation of 2D sphere and rectangle hitboxes.

Share this post


Link to post
Share on other sites

@ Skruge

That did it to me... many thanks! It can be so easy... :D

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Try something with:

$File = FileOpen("delete.txt", 0)
$Split = StringSplit(FileRead($File), Chr(10))

For $i = 1 To $Split[0]
    $Line = FileReadLine($File, $i)
    MsgBox(0, "", $Line)
Next

FileClose($File)

Didnt test it!

AlmarM

Why do you read the file twice? You should use one of these ways :D

$FileName = "delete.txt"
$Split = StringSplit( StringReplace(FileRead($FileName),@CR,"") , @LF)
For $i = 1 To $Split[0]
    MsgBox(0, '', $Split[$i])
Next
$File = FileOpen("delete.txt", 0)

While 1
    $Line = FileReadLine($File)
    If @error<>0 Then ExitLoop
    MsgBox(0, "", $Line)
WEnd

FileClose($File)

Besides, this was not what Stuempi wanted.

Edited by ProgAndy

*GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes

Share this post


Link to post
Share on other sites

Why do you read the file twice? You should use one of these ways :D

Hmm true >.<'

Besides, this was not what Stuempi wanted.

Oh, my fault!

Minesweeper

A minesweeper game created in autoit, source available.

_Mouse_UDF

An UDF for registering functions to mouse events, made in pure autoit.

2D Hitbox Editor

A 2D hitbox editor for quick creation of 2D sphere and rectangle hitboxes.

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