Sign in to follow this  
Followers 0
Glyph

Saving input to an .ini file

3 posts in this topic

#1 ·  Posted (edited)

; Script generated by AutoBuilder 0.6 Prototype

#include <GuiConstants.au3>
#include <misc.au3>
$user32 = ""
$dates = 4;inputs
#Region ### START Koda GUI section ### Form=
$form1= GuiCreate("Calender Eventer v0.1", 362, 140,-1, -1)

$Label_1 = GuiCtrlCreateLabel("Day", 20, 10, 40, 20, $SS_CENTER)
$Label_2 = GuiCtrlCreateLabel("Month", 80, 10, 50, 20, $SS_CENTER)
$Label_3 = GuiCtrlCreateLabel("Year", 160, 10, 30, 20, $SS_CENTER)

$Input1 = GUICtrlCreateInput(''&@MDAY, 10, 30, 50, 20)
$Input2 = GUICtrlCreateInput(''&@MON, 70, 30, 60, 20)
$Input3 = GUICtrlCreateInput(''&@YEAR, 140, 30, 70, 20)


$Label_4 = GuiCtrlCreateLabel("Event", 260, 10, 40, 20, $SS_CENTER)
$Input4 = GUICtrlCreateInput('Type the event here' , 230, 30, 130, 20)

$Save = GuiCtrlCreateButton("Save", 150, 100, 60, 30)

$Pic_1 = GuiCtrlCreatePic("back1.jpg", 10, 60, 130, 70)
$Pic_2 = GuiCtrlCreatePic("back2.jpg", 220, 60, 130, 70)

GuiSetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
    $nmsg = GuiGetMsg()
If $nMsg = $GUI_EVENT_CLOSE Then Exit

WEnd

If $nMsg = $Save Then
        Save()
        MsgBox(0, "", "Saved!")
    EndIf

Func Save()
    For $i = 1 To $dates
        IniWrite( @ScriptDir & '\Calender.ini', 'Day', $i, GUICtrlRead(Eval( "Input" & $i )))
        IniWrite( @ScriptDir & '\Calender.ini', 'Month', $i, GUICtrlRead(Eval( "Input" & $i )))
        IniWrite( @ScriptDir & '\Calender.ini', 'Year', $i, GUICtrlRead(Eval( "Input" & $i )))
        IniWrite( @ScriptDir & '\Calender.ini', 'Event', $i, GUICtrlRead(Eval( "Input" & $i )))
    Next 
    MsgBox(0, "", "Saved")
EndFunc

ini file

[Day]
1=
2=
3=
4=
[Month]
1=
2=
3=
4=
[Year]
1=
2=
3=
4=
[Event]
1=
2=
3=
4=

The logic seems right to me... But it just wont save!

Edited by backstabbed

tolle indicium

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

I hav commented out some of your code because I couldn't see what it was for, and I made some changes.

The Eval is for returning the value of a variable and I don't think you can use it for a control the way you were trying to.

Anyway, this works

; Script generated by AutoBuilder 0.6 Prototype but modified by Martin

#include <GuiConstants.au3>
#include <misc.au3>
$user32 = ""
$dates = 4;inputs
#Region ### START Koda GUI section ### Form=
$form1= GuiCreate("Calender Eventer v0.1", 362, 140,-1, -1)

$Label_1 = GuiCtrlCreateLabel("Day", 20, 10, 40, 20, $SS_CENTER)
$Label_2 = GuiCtrlCreateLabel("Month", 80, 10, 50, 20, $SS_CENTER)
$Label_3 = GuiCtrlCreateLabel("Year", 160, 10, 30, 20, $SS_CENTER)
dim $input[4]
$Input[0] = GUICtrlCreateInput(''&@MDAY, 10, 30, 50, 20)
$Input[1] = GUICtrlCreateInput(''&@MON, 70, 30, 60, 20)
$Input[2] = GUICtrlCreateInput(''&@YEAR, 140, 30, 70, 20)


$Label_4 = GuiCtrlCreateLabel("Event", 260, 10, 40, 20, $SS_CENTER)
$Input[3] = GUICtrlCreateInput('Type the event here' , 230, 30, 130, 20)
Dim $dwy[4] = ['Day','Month','Year','Event']
$Save = GuiCtrlCreateButton("Save", 150, 100, 60, 30)

$Pic_1 = GuiCtrlCreatePic("back1.jpg", 10, 60, 130, 70)
$Pic_2 = GuiCtrlCreatePic("back2.jpg", 220, 60, 130, 70)

GuiSetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
    $nmsg = GuiGetMsg()
If $nMsg = $GUI_EVENT_CLOSE Then Exit
   
   #cs For $i = 1 To 4;$quickmsgs;variable is not defined!!
        If $nMsg = Eval( "Button" & $i ) Then
            SplashTextOn( "", "Press The To Set", 200, 50, -1, -1, -1, -1, 20 )
            GUISetState( @SW_DISABLE )
            GUICtrlSetData(Eval( "Button" & $i ), getkey())
            SplashOff()
            GUISetState( @SW_ENABLE )
        EndIf
    Next
  #ce
  if $nmsg = $Save then ExitLoop
WEnd

If $nMsg = $Save Then
        Save()
        MsgBox(0, "", "Saved!")
    EndIf

Func Save()
    For $i = 0 To 3
        IniWrite( @ScriptDir & '\Calender.ini', $dwy[$i],$i, GUICtrlRead($input[$i]))
    Next
    MsgBox(0, "", "Saved")
EndFunc
Edited by martin

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

Lol i edited the post above... as ou can see i took a lil script from another file and didnt read it all over compltely... i just wanted the input part, anyway it works! thanks you!!!!


tolle indicium

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
Sign in to follow this  
Followers 0