Jump to content

how to GUICtrlCreateEdit saved in text file


Recommended Posts

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

Link to comment
Share on other sites

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

Signature - my forum contributions:

Spoiler

UDF:

LFN - support for long file names (over 260 characters)

InputImpose - impose valid characters in an input control

TimeConvert - convert UTC to/from local time and/or reformat the string representation

AMF - accept multiple files from Windows Explorer context menu

DateDuration -  literal description of the difference between given dates

Apps:

Touch - set the "modified" timestamp of a file to current time

Show For Files - tray menu to show/hide files extensions, hidden & system files, and selection checkboxes

SPDiff - Single-Pane Text Diff

 

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

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

  • Recently Browsing   0 members

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