vin1 Posted September 6, 2018 Posted September 6, 2018 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) expandcollapse popup#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
markyrocks Posted September 6, 2018 Posted September 6, 2018 (edited) 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 September 6, 2018 by markyrocks Spoiler "I Believe array math to be potentially fatal, I may be dying from array math poisoning"
markyrocks Posted September 7, 2018 Posted September 7, 2018 (edited) 30 minutes ago, vin1 said: gives a 0 as the only result O sorry I'm rusty change the += to &= The math operator probably makes the variable expect a number Edited September 7, 2018 by markyrocks Spoiler "I Believe array math to be potentially fatal, I may be dying from array math poisoning"
bolthead Posted September 7, 2018 Posted September 7, 2018 Try changing GUICtrlSetData($edit, $result1s[$results1]) to GUICtrlSetData($edit, $result1s[$results1] & @CRLF, 1)
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