Jump to content

multiline add text to edit box


vin1
 Share

Recommended Posts

i have a script that let you type text then give a random result on an output box, writes the result on a text file and tries to add the result text to an edit box but doesn't support multiple lines. I want the script to add lines of results on the edit box (as a log of results)

#include <GUIConstantsEx.au3>
#include <EditConstants.au3>
#include <StaticConstants.au3>
#include <File.au3>
#include <Date.au3>


Global $result1s[3]=["one", "two", "three"]

_Main()

Func _Main()

    Local $button1
    Local $output, $die, $msg, $results1
    Local $file = FileOpen("test.txt", 1)
    Local $g_idEdit

    GUICreate("test", 600, 400, -1, -1)
    $button1 = GUICtrlCreateButton("Result", 432, 350, 80, 40)
    $sText = $results1
    $edit = GUICtrlCreateEdit($sText & @CRLF & $sText & @CRLF & $sText, 60, 50, 450, 300, BitOr($GUI_SS_DEFAULT_EDIT, $ES_READONLY))
    $output1 = GUICtrlCreateInput("", 60, 30, 450, 20, BitOR($ES_CENTER, $ES_READONLY))

    $g_idEdit = GUICtrlCreateEdit("", 60, 10, 450, 20, $SS_LEFT)

    $die = GUICtrlCreateLabel("", 700, 500, 700, 20, $SS_SUNKEN)
    GUICtrlSetFont($output, 8, 800, "", "Verdana")
    GUISetState()



    ; Run the GUI until the dialog is closed
    While 1
        $msg = GUIGetMsg()
        Select
            Case $msg = $button1

                $results1 = Random(1, 2, 1)
                GUICtrlSetData($output1, $result1s[$results1])
                GUICtrlSetData($edit, $result1s[$results1])
                $read1 = GUICtrlRead($output1)

            FileWriteLine($file, _NowDate()& " " & _nowTime() & " " &GUICtrlRead($g_idEdit))
            FileWriteLine($file, _NowDate()& " " & _nowTime() & " " &$read1)



        EndSelect
        If $msg = $GUI_EVENT_CLOSE Then ExitLoop
    WEnd
EndFunc   ;==>_Main

 

 

Screenshot_3.png

Link to comment
Share on other sites

Local $TempResult
While 1
        $msg = GUIGetMsg()
        Select
            Case $msg = $button1
                
                $results1 = Random(1, 2, 1)
                $TempResult+=$result1s[$results1] & @CRLF ;these variable names.... $Random would have been much better for the ummm random number...
                GUICtrlSetData($output1, $TempResult)
                GUICtrlSetData($edit, $TempResult)
                $read1 = GUICtrlRead($output1)

            FileWriteLine($file, _NowDate()& " " & _nowTime() & " " &GUICtrlRead($g_idEdit))
            FileWriteLine($file, _NowDate()& " " & _nowTime() & " " &$read1)



        EndSelect
        If $msg = $GUI_EVENT_CLOSE Then ExitLoop
    WEnd
EndFunc   ;==>_Main

worth a shot.

Edited by markyrocks
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

×
×
  • Create New...