Jump to content
Sign in to follow this  
Drew

Annoying Function

Recommended Posts

Drew

Alright. Everything works except for the Value written to the key. ( The key shows fine... ).

When I look in the data folder, the .ini is made , everything is written correctly except the values. ( <- The most important part of a .ini? )

Oh and the name of the .ini , sorry. I've tested this many times and come to the conclusion of these facts:

1. The name of the .ini is ALWAYS 12.

2. The value of the first key is ALWAYS 13

3. The value of the second key is ALWAYS 14

And so on for all my values. Sequential order starting @ 12 for whatever reason. Heres my function , please enlighten me if you see the cause.

Func _Add()
    #include <GUIConstants.au3>

    #region ### START Koda GUI section ### Form=
    $Form1 = GUICreate("Adding a DVD", 319, 344, 416, 194)
    $Label1 = GUICtrlCreateLabel("Name:", 24, 72, 60, 30)
    GUICtrlSetFont(-1, 14, 400, 0, "Palatino Linotype")
    $Label2 = GUICtrlCreateLabel("Genre:", 24, 112, 59, 30)
    GUICtrlSetFont(-1, 14, 400, 0, "Palatino Linotype")
    $Label3 = GUICtrlCreateLabel("Subtitles:", 24, 152, 80, 30)
    GUICtrlSetFont(-1, 14, 400, 0, "Palatino Linotype")
    $Label4 = GUICtrlCreateLabel("Year:", 24, 192, 48, 30)
    GUICtrlSetFont(-1, 14, 400, 0, "Palatino Linotype")
    $Label5 = GUICtrlCreateLabel("Length:", 24, 232, 68, 30)
    GUICtrlSetFont(-1, 14, 400, 0, "Palatino Linotype")
    $NameInput = GUICtrlCreateInput("NameInput", 112, 72, 177, 21)
    $GenreInput = GUICtrlCreateInput("GenreInput", 112, 112, 177, 21)
    $SubtiltleInput = GUICtrlCreateInput("SubtiltleInput", 112, 152, 177, 21)
    $YearInput = GUICtrlCreateInput("YearInput", 112, 192, 177, 21)
    $LengthInput = GUICtrlCreateInput("LengthInput", 112, 232, 177, 21)
    $Button1 = GUICtrlCreateButton("Add", 88, 280, 137, 33, 0)
    GUICtrlSetFont(-1, 14, 400, 0, "MS Sans Serif")
    $Label6 = GUICtrlCreateLabel("DvD Addition Form", 56, 16, 223, 33)
    GUICtrlSetFont(-1, 18, 800, 4, "MS Sans Serif")
    GUISetState(@SW_SHOW)
    #endregion ### START Koda GUI section ### Form=

    While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
            Case $GUI_EVENT_CLOSE
            Exit
            Case $Button1
                IniWrite( @ScriptDir&"\Data\"&$NameInput&".ini", "Details", "Genre", $GenreInput)
                IniWrite( @ScriptDir&"\Data\"&$NameInput&".ini", "Details", "Subtitles", $SubtiltleInput)
                IniWrite( @ScriptDir&"\Data\"&$NameInput&".ini", "Details", "Year", $YearInput)
                IniWrite( @ScriptDir&"\Data\"&$NameInput&".ini", "Details", "Length", $LengthInput)
                GuiDelete()
        EndSwitch
    WEnd
EndFunc

Share this post


Link to post
Share on other sites
Hiyoal

The values you are inputting into the Ini file are not the "Read Values"

Use GUICtrlRead($input) and see what that comes up with

Eg.

IniWrite( @ScriptDir&"\Data\"&$NameInput&".ini", "Details", "Genre", GUICtrlRead($GenreInput))

Hiyoal

Edited by Hiyoal

Share this post


Link to post
Share on other sites
Drew

Very good point. Wasn't thinking logically in that tense. I'll try that out.

Share this post


Link to post
Share on other sites
Drew

Alright that worked, but lets use this thread to get 2 birds with one stone.

For whatever reason, the Add button will only work 1 time. To add another , I must restart the program and do it.

It's already in a while statement... so eh?

Share this post


Link to post
Share on other sites
Hiyoal

What are you saying?!

I dont really understand at all why it wouldnt work any other times so could you please upload the full script so I can take a look.

Hiyoal

Share this post


Link to post
Share on other sites
Drew

Full script isn't needed. The rest of the script has nothing to do with that function , other than this part:

Case $Add

_Add()

Where you press that button and it calls the function _Add(). Adding the entire script will create a jumbled mess.

Atm ... I do it once.. works fine. I try it again and its like the buttons not a button. I click it , nothing happens.

EDIT

Here's an up-to-date version of the function...

Func _Add()
    #include <GUIConstants.au3>

    #region ### START Koda GUI section ### Form=
    $Form1 = GUICreate("Adding a DVD", 319, 344, 416, 194)
    $Label1 = GUICtrlCreateLabel("Name:", 24, 72, 60, 30)
    GUICtrlSetFont(-1, 14, 400, 0, "Palatino Linotype")
    $Label2 = GUICtrlCreateLabel("Genre:", 24, 112, 59, 30)
    GUICtrlSetFont(-1, 14, 400, 0, "Palatino Linotype")
    $Label3 = GUICtrlCreateLabel("Subtitles:", 24, 152, 80, 30)
    GUICtrlSetFont(-1, 14, 400, 0, "Palatino Linotype")
    $Label4 = GUICtrlCreateLabel("Year:", 24, 192, 48, 30)
    GUICtrlSetFont(-1, 14, 400, 0, "Palatino Linotype")
    $Label5 = GUICtrlCreateLabel("Length:", 24, 232, 68, 30)
    GUICtrlSetFont(-1, 14, 400, 0, "Palatino Linotype")
    $NameInput = GUICtrlCreateInput("NameInput", 112, 72, 177, 21)
    $GenreInput = GUICtrlCreateInput("GenreInput", 112, 112, 177, 21)
    $SubtiltleInput = GUICtrlCreateInput("SubtiltleInput", 112, 152, 177, 21)
    $YearInput = GUICtrlCreateInput("YearInput", 112, 192, 177, 21)
    $LengthInput = GUICtrlCreateInput("LengthInput", 112, 232, 177, 21)
    $Button1 = GUICtrlCreateButton("Add", 88, 280, 137, 33, 0)
    GUICtrlSetFont(-1, 14, 400, 0, "MS Sans Serif")
    $Label6 = GUICtrlCreateLabel("DvD Addition Form", 56, 16, 223, 33)
    GUICtrlSetFont(-1, 18, 800, 4, "MS Sans Serif")
    GUISetState(@SW_SHOW)
    #endregion ### START Koda GUI section ### Form=

    While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
            Case $GUI_EVENT_CLOSE
            Exit
            Case $Button1
                IniWrite( @ScriptDir&"\Data\"&GuiCtrlRead($NameInput)&".ini", "Details", "Genre", GuiCtrlRead($GenreInput))
                IniWrite( @ScriptDir&"\Data\"&GuiCtrlRead($NameInput)&".ini", "Details", "Subtitles", GuiCtrlRead($SubtiltleInput))
                IniWrite( @ScriptDir&"\Data\"&GuiCtrlRead($NameInput)&".ini", "Details", "Year", GuiCtrlRead($YearInput))
                IniWrite( @ScriptDir&"\Data\"&GuiCtrlRead($NameInput)&".ini", "Details", "Length", GuiCtrlRead($LengthInput))
                GUICtrlCreateListViewItem( ""&GuiCtrlRead($NameInput)&"|"&GuiCtrlRead($GenreInput)&"|"&GuiCtrlRead($SubtiltleInput)&"|"&GuiCtrlRead($YearInput)&"|"&GuiCtrlRead($LengthInput), $listview1)
                GuiDelete()
        EndSwitch
    WEnd
EndFunc
Edited by Drew

Share this post


Link to post
Share on other sites
Hiyoal

Try this:

Func _Add()

#include <GUIConstants.au3>

#region ### START Koda GUI section ### Form=

$Form1 = GUICreate("Adding a DVD", 319, 344, 416, 194)

$Label1 = GUICtrlCreateLabel("Name:", 24, 72, 60, 30)

GUICtrlSetFont(-1, 14, 400, 0, "Palatino Linotype")

$Label2 = GUICtrlCreateLabel("Genre:", 24, 112, 59, 30)

GUICtrlSetFont(-1, 14, 400, 0, "Palatino Linotype")

$Label3 = GUICtrlCreateLabel("Subtitles:", 24, 152, 80, 30)

GUICtrlSetFont(-1, 14, 400, 0, "Palatino Linotype")

$Label4 = GUICtrlCreateLabel("Year:", 24, 192, 48, 30)

GUICtrlSetFont(-1, 14, 400, 0, "Palatino Linotype")

$Label5 = GUICtrlCreateLabel("Length:", 24, 232, 68, 30)

GUICtrlSetFont(-1, 14, 400, 0, "Palatino Linotype")

$NameInput = GUICtrlCreateInput("NameInput", 112, 72, 177, 21)

$GenreInput = GUICtrlCreateInput("GenreInput", 112, 112, 177, 21)

$SubtiltleInput = GUICtrlCreateInput("SubtiltleInput", 112, 152, 177, 21)

$YearInput = GUICtrlCreateInput("YearInput", 112, 192, 177, 21)

$LengthInput = GUICtrlCreateInput("LengthInput", 112, 232, 177, 21)

$Button1 = GUICtrlCreateButton("Add", 88, 280, 137, 33, 0)

GUICtrlSetFont(-1, 14, 400, 0, "MS Sans Serif")

$Label6 = GUICtrlCreateLabel("DvD Addition Form", 56, 16, 223, 33)

GUICtrlSetFont(-1, 18, 800, 4, "MS Sans Serif")

GUISetState(@SW_SHOW)

#endregion ### START Koda GUI section ### Form=

While 1

$nMsg = GUIGetMsg()

Switch $nMsg

Case $GUI_EVENT_CLOSE

Exit

Case $Button1

IniWrite( @ScriptDir&"\Data\"&$NameInput&".ini", "Details", "Genre", $GenreInput)

IniWrite( @ScriptDir&"\Data\"&$NameInput&".ini", "Details", "Subtitles", $SubtiltleInput)

IniWrite( @ScriptDir&"\Data\"&$NameInput&".ini", "Details", "Year", $YearInput)

IniWrite( @ScriptDir&"\Data\"&$NameInput&".ini", "Details", "Length", $LengthInput)

GuiDelete($form1)

ExitLoop

EndSwitch

WEnd

EndFunc

Edited by Hiyoal

Share this post


Link to post
Share on other sites
martin

Full script isn't needed. The rest of the script has nothing to do with that function , other than this part:

Case $Add

_Add()

Where you press that button and it calls the function _Add(). Adding the entire script will create a jumbled mess.

Atm ... I do it once.. works fine. I try it again and its like the buttons not a button. I click it , nothing happens.

EDIT

Here's an up-to-date version of the function...

Func _Add()
    #include <GUIConstants.au3>

    #region ### START Koda GUI section ### Form=
    $Form1 = GUICreate("Adding a DVD", 319, 344, 416, 194)
    $Label1 = GUICtrlCreateLabel("Name:", 24, 72, 60, 30)
    GUICtrlSetFont(-1, 14, 400, 0, "Palatino Linotype")
    $Label2 = GUICtrlCreateLabel("Genre:", 24, 112, 59, 30)
    GUICtrlSetFont(-1, 14, 400, 0, "Palatino Linotype")
    $Label3 = GUICtrlCreateLabel("Subtitles:", 24, 152, 80, 30)
    GUICtrlSetFont(-1, 14, 400, 0, "Palatino Linotype")
    $Label4 = GUICtrlCreateLabel("Year:", 24, 192, 48, 30)
    GUICtrlSetFont(-1, 14, 400, 0, "Palatino Linotype")
    $Label5 = GUICtrlCreateLabel("Length:", 24, 232, 68, 30)
    GUICtrlSetFont(-1, 14, 400, 0, "Palatino Linotype")
    $NameInput = GUICtrlCreateInput("NameInput", 112, 72, 177, 21)
    $GenreInput = GUICtrlCreateInput("GenreInput", 112, 112, 177, 21)
    $SubtiltleInput = GUICtrlCreateInput("SubtiltleInput", 112, 152, 177, 21)
    $YearInput = GUICtrlCreateInput("YearInput", 112, 192, 177, 21)
    $LengthInput = GUICtrlCreateInput("LengthInput", 112, 232, 177, 21)
    $Button1 = GUICtrlCreateButton("Add", 88, 280, 137, 33, 0)
    GUICtrlSetFont(-1, 14, 400, 0, "MS Sans Serif")
    $Label6 = GUICtrlCreateLabel("DvD Addition Form", 56, 16, 223, 33)
    GUICtrlSetFont(-1, 18, 800, 4, "MS Sans Serif")
    GUISetState(@SW_SHOW)
    #endregion ### START Koda GUI section ### Form=

    While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
            Case $GUI_EVENT_CLOSE
            Exit
            Case $Button1
                IniWrite( @ScriptDir&"\Data\"&GuiCtrlRead($NameInput)&".ini", "Details", "Genre", GuiCtrlRead($GenreInput))
                IniWrite( @ScriptDir&"\Data\"&GuiCtrlRead($NameInput)&".ini", "Details", "Subtitles", GuiCtrlRead($SubtiltleInput))
                IniWrite( @ScriptDir&"\Data\"&GuiCtrlRead($NameInput)&".ini", "Details", "Year", GuiCtrlRead($YearInput))
                IniWrite( @ScriptDir&"\Data\"&GuiCtrlRead($NameInput)&".ini", "Details", "Length", GuiCtrlRead($LengthInput))
                GUICtrlCreateListViewItem( ""&GuiCtrlRead($NameInput)&"|"&GuiCtrlRead($GenreInput)&"|"&GuiCtrlRead($SubtiltleInput)&"|"&GuiCtrlRead($YearInput)&"|"&GuiCtrlRead($LengthInput), $listview1)
                GuiDelete()
        EndSwitch
    WEnd
EndFunc
After GuiDelete() you should have a line GuiSwitch($WhatevertheGuiHandleIsForTheWindowWithTheAddButton)

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

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  

×