RafaelGioffi Posted March 12, 2022 Share Posted March 12, 2022 Hey guys! I'm trying to make a script that reads all lines from a txt file and inserts it into a GuiCtrlCreateEdit (or GuiCtrlCreateInput with multilines) but without success... Does anyone have any idea how to do this? I've used the following code but it doesn't work... Global $arqlinhas2[] = ["8", "5"] ;~ random values... _FileReadToArray($txtCorpoEmail, $arqlinhas2) Global $cont2 = $arqlinhas2[0] ;~ increment array but start with 0... Global $linha2[$cont2 + 1] If FileExists($txtCorpoEmail) Then For $i = 1 To $cont2 $linha2[$i] = $arqlinhas2[$i] Next EndIf $txtEmail = GUICtrlCreateEdit("", 120, 230, 490, 100, BitOR($ES_WANTRETURN, $ES_MULTILINE, $ES_AUTOVSCROLL, $ES_AUTOHSCROLL)) $temp = _ArrayExtract($linha2) GUICtrlSetData($txtEmail, $temp) Link to comment Share on other sites More sharing options...
Subz Posted March 12, 2022 Share Posted March 12, 2022 Try something like: #include <Array.au3> #include <EditConstants.au3> #include <File.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Global $g_aFilePath, $g_sFilePath = @ScriptDir & "\Example.txt" _FileReadToArray($g_sFilePath, $g_aFilePath) Example() Func Example() GUICreate("Example", 200, 100) Local $idExample = GUICtrlCreateEdit("" & @CRLF, 10, 10, 180, 80, $ES_AUTOVSCROLL + $WS_VSCROLL) GUICtrlSetData($idExample, _ArrayToString($g_aFilePath, @CRLF, 1)) GUISetState(@SW_SHOW) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd GUIDelete() EndFunc ;==>Example Link to comment Share on other sites More sharing options...
RafaelGioffi Posted March 14, 2022 Author Share Posted March 14, 2022 Sorry, I didn't try that, but I did and it worked but with a "bug"... ;~ Array... Global $arqlinhas2[] = ["8", "5"] _FileReadToArray($txtCorpoEmail, $arqlinhas2) Global $cont2 = $arqlinhas2[0] ;~ increment array position to 1... Global $linha2[$cont2 + 1] ;~ read Email.txt file... If FileExists($txtCorpoEmail) Then For $i = 1 To $cont2 $linha2[$i] = $arqlinhas2[$i] Next EndIf $Label11 = GUICtrlCreateLabel("Corpo do e-mail a ser enviado aos clientes: ", 13, 233, 101, 40) $txtEmail = GUICtrlCreateEdit("", 120, 230, 490, 100, BitOR($ES_WANTRETURN, $ES_MULTILINE, $ES_AUTOVSCROLL, $ES_AUTOHSCROLL)) ;~ fill the Edit... $temp = _ArrayExtract($linha2) GUICtrlSetData($txtEmail, $temp) GUICtrlSetData($txtEmail, StringReplace(_ArrayToString($linha2), "|", @CRLF)) ;~ fim do preenchimento... the only problem is that it fills the Edit by skipping the first line for reading with "|" at first. Link to comment Share on other sites More sharing options...
ad777 Posted March 14, 2022 Share Posted March 14, 2022 @RafaelGioffi use FileRead: Local $g_sFilePath = ".\test.txt" Local $READ = FileRead($g_sFilePath, -1) Local $idExample = GUICtrlCreateEdit("" & @CRLF, 10, 10, 180, 80, $ES_AUTOVSCROLL + $WS_VSCROLL) GUICtrlSetData($idExample, $READ) iam ِAutoit programmer. best thing in life is to use your Brain to Achieve everything you want. Link to comment Share on other sites More sharing options...
RafaelGioffi Posted March 23, 2022 Author Share Posted March 23, 2022 Neither of the two solutions worked. Thank you both anyway! Hugs! Link to comment Share on other sites More sharing options...
Subz Posted March 23, 2022 Share Posted March 23, 2022 As per my example above you needed to use the following: GUICtrlSetData($txtEmail, _ArrayToString($linha2, @CRLF)) 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