way1000

how to GUICtrlCreateEdit saved in text file

5 posts in this topic

i have a script that allows input of text (words), i'm trying to save the words to a text file but it saves as a number instead of words

 

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


Global $result1s[3]=["text 1", "text 2", "text 3"]

_Main()

Func _Main()

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

    GUICreate("test", 600, 200, -1, -1)
    $button1 = GUICtrlCreateButton("Result", 460, 110, 50, 30)

    $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])
                $read1 = GUICtrlRead($output1)


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



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

how to fix it

Share this post


Link to post
Share on other sites



Use Guictrlread.

 

Saludos

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

i think what Danyfirex means is that you save the control id $g_idEdit (which is a number), instead of reading it to save its contents. replace this line:

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

with this:

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

 

Edited by orbs
1 person likes this

Share this post


Link to post
Share on other sites
25 minutes ago, orbs said:

i think what Danyfirex means is that you save the control id $g_idEdit (which is a number), instead of reading it to save its contents. replace this line:

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

with this:

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

 

Hello. I'm not so good answering lol

Saludos

Share this post


Link to post
Share on other sites

thank you so much, both of you

 

it works

Share this post


Link to post
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