Jump to content

Recommended Posts

Posted

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)

 

Posted

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

 

Posted

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.

  • 2 weeks later...

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...