Jump to content

Help with FileWrite from InputBoxes!


Recommended Posts

Hi everybody!

It's been a long time from my last post, but now i have a new problem that I hope you can resolve!

So here it is: I've created a GUI with 3 input boxes and one button. You insert year, month and day in the inputboxes and press the button that will create a txt file inserting inputboxes values.

My problem it's that FileWrite does not insert my inputbox variables, but it insert YEAR=4, MONTH=3, DAY=13!

Here's my code: (I used KODA)

#Region ### START Koda GUI section ###
GUICreate("MY GUI", 135, 221, 195, 125)
$MESE_input = GUICtrlCreateInput("", 62, 72, 41, 21)
$ANNO_input = GUICtrlCreateInput("", 62, 44, 41, 21)
$Anno = GUICtrlCreateLabel("Anno:", 22, 48, 32, 17)
$Mese = GUICtrlCreateLabel("Mese:", 22, 77, 33, 17)
$PATCHbtn = GUICtrlCreateButton("1.) PATCH FILE", 8, 128, 121, 25, 0)
$GIORNO_input = GUICtrlCreateInput("", 62, 100, 41, 21)
$Label5 = GUICtrlCreateLabel("Giorno:", 21, 102, 38, 17)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

        Case $PATCHbtn
            FileWrite("FILE.txt", "[KEY_DATE]" & @CRLF & "YEAR=" & $ANNO_input & @CRLF & "MONTH=" & $MESE_input & @CRLF & "DAY=" & $GIORNO_input & @CRLF & "[NEW_DATE]" & @CRLF & "YEAR=2020" & @CRLF & "MONTH=12" & @CRLF & "DAY=31")
            
    EndSwitch
WEnd

Attached there's the file that FileWrite has to create.

I hope in your support!

Best regards, NGM

FILE.txt

Edited by ned98
Link to comment
Share on other sites

  • Moderators

ned98,

You need to use GUICtrlRead to get the content of the Inputs - at the moment you are just writing the ControlIDs. :blink:

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

You must read input before writing it to txt file!

Check it:

#Region ### START Koda GUI section ###
GUICreate("MY GUI", 135, 221, 195, 125)
$MESE_input = GUICtrlCreateInput("", 62, 72, 41, 21)
$ANNO_input = GUICtrlCreateInput("", 62, 44, 41, 21)
$Anno = GUICtrlCreateLabel("Anno:", 22, 48, 32, 17)
$Mese = GUICtrlCreateLabel("Mese:", 22, 77, 33, 17)
$PATCHbtn = GUICtrlCreateButton("1.) PATCH FILE", 8, 128, 121, 25, 0)
$GIORNO_input = GUICtrlCreateInput("", 62, 100, 41, 21)
$Label5 = GUICtrlCreateLabel("Giorno:", 21, 102, 38, 17)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
    Case $PATCHbtn
$ANNO_input_read = GUICtrlRead($ANNO_input)
$MESE_input_read = GUICtrlRead($MESE_input)
$GIORNO_input_read = GUICtrlRead($GIORNO_input)
            FileWrite("FILE.txt", "[KEY_DATE]" & @CRLF & "YEAR=" & $ANNO_input_read & @CRLF & "MONTH=" & $MESE_input_read & @CRLF & "DAY=" & $GIORNO_input_read & @CRLF & "[NEW_DATE]" & @CRLF & "YEAR=2020" & @CRLF & "MONTH=12" & @CRLF & "DAY=31")

    EndSwitch
WEnd
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...