Stuempi Posted June 5, 2009 Posted June 5, 2009 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)
Skruge Posted June 5, 2009 Posted June 5, 2009 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]
AlmarM Posted June 6, 2009 Posted June 6, 2009 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.
Stuempi Posted June 6, 2009 Author Posted June 6, 2009 @ Skruge That did it to me... many thanks! It can be so easy...
ProgAndy Posted June 6, 2009 Posted June 6, 2009 (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! AlmarMWhy do you read the file twice? You should use one of these ways $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 June 6, 2009 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
AlmarM Posted June 6, 2009 Posted June 6, 2009 Why do you read the file twice? You should use one of these ways 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.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now