Groumphy Posted June 4, 2005 Share Posted June 4, 2005 Hello, I try to include a textual file of some lines in a control (Label). Unfortunately, each tests indicates an error to me. Here my method : 1 - To open the textual file 2 - To count the lines 3 - For each counted line, I read the lines in Array 4 - Concatenation of all Array in a variable 5 - Posting of the variable in control Isn't it easier to read a file by using IniRead ? Thank you for your councils... Groumphy ----------------------GroumphyMore information about me [Fr] Link to comment Share on other sites More sharing options...
Developers Jos Posted June 4, 2005 Developers Share Posted June 4, 2005 Hello, I try to include a textual file of some lines in a control (Label).Unfortunately, each tests indicates an error to me.Here my method :1 - To open the textual file 2 - To count the lines 3 - For each counted line, I read the lines in Array4 - Concatenation of all Array in a variable 5 - Posting of the variable in controlIsn't it easier to read a file by using IniRead ? Thank you for your councils...Groumphy<{POST_SNAPBACK}>what about just reading the whole file into a variable and putting that into your Label ?Something like:$Filename="YourFileName" $FileText = FileRead($FIlename,FileGetSize($FileName)) $FileText = StringReplace($FileName,@CRLF,@LF) $ControlHandle = GUICtrlCreateLabel($filetext,10,10) ; - or - GUICtrlSetData($ControlHandle,$FileText) SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
Groumphy Posted June 4, 2005 Author Share Posted June 4, 2005 Hello Jdeb,Thank you for your assistance.So easy ?!! Waw...Unfortunately that does not function. That registered (post) the name of the textual file and not the contents.I thought thereafter that it was initially necessary to open the textual file but the result is the same one.#include <GUIConstants.au3> GUICreate("My Gui", 200, 200, -1, -1) GUISetState(@SW_SHOW) $Filename= "test.txt" $FileText = FileRead(FileOpen($Filename, 0), FileGetSize($FileName)) $FileText = StringReplace($FileName, @CRLF, @LF) $ControlHandle = GUICtrlCreateLabel($FileText, 10, 10, 180, 180) ; - or - ; GUICtrlSetData($ControlHandle, $FileText) While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then ExitLoop WendHere the result :Not cool ----------------------GroumphyMore information about me [Fr] Link to comment Share on other sites More sharing options...
MHz Posted June 4, 2005 Share Posted June 4, 2005 You need to store your FileOpen into a variable, so you can close it. Your StringReplace was trying to work the file, rather then the FileRead return. Try this: #include <GUIConstants.au3> GUICreate("My Gui", 200, 200, -1, -1) GUISetState(@SW_SHOW) $Filename= "test.txt" $handle = FileOpen($Filename, 0) $FileText = FileRead($handle, FileGetSize($Filename)) If @error = -1 Then Exit $FileText = StringReplace($FileText, @CRLF, @LF) $ControlHandle = GUICtrlCreateLabel($FileText, 10, 10, 180, 180) ; - or - ; GUICtrlSetData($ControlHandle, $FileText) FileClose($handle) While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then ExitLoop Wend Link to comment Share on other sites More sharing options...
Groumphy Posted June 4, 2005 Author Share Posted June 4, 2005 Hello, Ok, it's now perfect !! Thanks... ----------------------GroumphyMore information about me [Fr] Link to comment Share on other sites More sharing options...
Groumphy Posted June 4, 2005 Author Share Posted June 4, 2005 Why not this : Func _InsertTxtFileToLabel($iFilename, $iLeft, $iTop, $iHeight, $iWidth) $iHandle = FileOpen($iFilename, 0) $iFileText = FileRead($iHandle, FileGetSize($iFilename)) If @error = -1 Then Exit $iFileText = StringReplace($iFileText, @CRLF, @LF) $iVarCtrl = GUICtrlCreateLabel($iFileText, $iLeft, $iTop, $iHeight, $iWidth) ; - or - ; GUICtrlSetData($ControlHandle, $FileText) FileClose($iHandle) EndFunc #include <GUIConstants.au3> GUICreate("My Gui", 200, 200, -1, -1) GUISetState(@SW_SHOW) _InsertTxtFileToLabel("test.txt", "10", "10", "60", "60") _InsertTxtFileToLabel("test.txt", "10", "90", "180", "100") While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then ExitLoop Wend Easylytoo Gniark ----------------------GroumphyMore information about me [Fr] Link to comment Share on other sites More sharing options...
Groumphy Posted September 5, 2006 Author Share Posted September 5, 2006 Hello, In relation with this topics, I've a small problem. I make a small derivation of the previous script and in place of a GUICtrlCreateLabel, I use a GUICtrlCreateInput and the text is well include in the label but I've no scroll in the Input and the text of my textfile stay on one line... Where is my error ? Here is my code : #include <GUIConstants.au3> GUICreate("My Gui", 200, 200, -1, -1) GUISetState(@SW_SHOW) $Filename= "test.txt" $handle = FileOpen($Filename, 0) $FileText = FileRead($handle, FileGetSize($Filename)) If @error = -1 Then Exit $FileText = StringReplace($FileText, @CRLF, @LF) $ControlHandle = GUICtrlCreateInput($FileText, 10, 10, 180, 180, $ES_AUTOVSCROLL + $ES_READONLY) ; - or - ; GUICtrlSetData($ControlHandle, $FileText) FileClose($handle) While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then ExitLoop Wend The problem come of then "Enter/Cariage". I've try to change the StringReplace @CRLF, @LF by @LF, @CRLF but it's the same. I've try too with : Chr(13), Chr(10). Is it possible to have an insertion of a textfile in an Input with a scroll ? Thanks for your help, G. ----------------------GroumphyMore information about me [Fr] Link to comment Share on other sites More sharing options...
Groumphy Posted September 5, 2006 Author Share Posted September 5, 2006 Hello, I've found the problem. There was a bad formating of the textfile and I much use an Edit at place than an Input. Thanks for your help and sorry for the disturb. G. ----------------------GroumphyMore information about me [Fr] Link to comment Share on other sites More sharing options...
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