Jump to content

MsgBox with FileReadLine


Recommended Posts

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)
Link to comment
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.

Link to comment
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

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

Link to comment
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.

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