Jump to content

IniWrite Problem


Recommended Posts

I am writing a script to become a screen saver, but i want it to be configurable when not actually used as a screen saver

here it the INI part of my code,for some reason, it never writes ini values in a way other than numbers

#Include <GuiConstants.au3>

opt('WinTitleMatchMode', 4)

Global $window_[2000], $x, $y, $int, $label_[2000],$text, $Speed, $speed

If StringInStr($CmdLineRaw, "/S") Then
    SaverWindow()
ElseIf StringInStr($CmdLineRaw, "/P") Then
    Exit
Else
    ConfigWindow()
Endif

Func ConfigWindow()
    $config = GUICreate("Screen Saver Configurations", 200, 150, -1, -1)
    GUICtrlCreateLabel("Text: ", 10, 10)
    $text = GUICtrlCreateInput("", 10, 30)
    GUICtrlCreateLabel("Speed: ", 10, 60)
    $speed= GUICtrlCreateInput("", 10, 90)
    $go = GUICtrlCreateButton("Apply", 10, 120)
    GuiSetState()
    
    While 1
        $msg = GUIGetMsg()
        If $msg = $GUI_EVENT_CLOSE Then Exit
        If $msg = $go then FileMake()
    Wend
EndFunc

Func FileMake()
    If not FileExists(@ScriptDir&"\SaverConfig.ini") Then
        FileOpen(@ScriptDir&"\SaverConfig.ini", 2)
        IniWrite("SaverConfig.ini", "Configs", "1", $text)
        IniWrite("SaverConfig.ini", "Configs", "2", $speed)
    Else
        IniWrite("SaverConfig.ini", "Configs", "1", $text)
        IniWrite("SaverConfig.ini", "Configs", "2", $speed)
    EndIf
EndFunc

Any clue why?

TY

Link to comment
Share on other sites

FileOpen for IniWrite? Remove that line as you are opening a handle which could prevent the IniWrite. IniWrite does not use handles. IniWrite will create the file if it does not exist.

And besides, you never actually use the handle as a variable in your code to close the handle.

:D

Edited by MHz
Link to comment
Share on other sites

Just a hunch

But do you need the FileOpen for OverWrite???

HardCopy

Func FileMake()
    If not FileExists(@ScriptDir&"\SaverConfig.ini") Then
;;;;        FileOpen(@ScriptDir&"\SaverConfig.ini", 2)
        IniWrite("SaverConfig.ini", "Configs", "1", $text)
        IniWrite("SaverConfig.ini", "Configs", "2", $speed)
    Else
        IniWrite("SaverConfig.ini", "Configs", "1", $text)
        IniWrite("SaverConfig.ini", "Configs", "2", $speed)
    EndIf
EndFunc

Contributions: UDF _DateYearFirstChildren are like Farts, you can just about stand your own.Why am I not a Vegetarian?...Well...my ancestors didn't fight & evolve to the Top of the food chain for me to survive on Salad

Link to comment
Share on other sites

Just a hunch

But do you need the FileOpen for OverWrite???

HardCopy

Func FileMake()
    If not FileExists(@ScriptDir&"\SaverConfig.ini") Then
;;;;        FileOpen(@ScriptDir&"\SaverConfig.ini", 2)
        IniWrite("SaverConfig.ini", "Configs", "1", $text)
        IniWrite("SaverConfig.ini", "Configs", "2", $speed)
    Else
        IniWrite("SaverConfig.ini", "Configs", "1", $text)
        IniWrite("SaverConfig.ini", "Configs", "2", $speed)
    EndIf
EndFunc
Yeah that was why i put the fileopen in there, so it would overwrite the thing and create it

but when i got rid of it, it still just wrote both key values to 4 and 6

i don't know why

Edited by Paulie
Link to comment
Share on other sites

Yeah that was why i put the fileopen in there, so it would overwrite the thing and create it

but when i got rid of it, it still just wrote both key values to 4 and 6

i don't know why

Ok, now if you actually GuiCtrlRead the controls $text and $speed

and save the contents u may get what you need..

currrently it is just saving your ControlIDs 6 + 4 respectively

HardCopy

Contributions: UDF _DateYearFirstChildren are like Farts, you can just about stand your own.Why am I not a Vegetarian?...Well...my ancestors didn't fight & evolve to the Top of the food chain for me to survive on Salad

Link to comment
Share on other sites

Ok, now if you actually GuiCtrlRead the controls $text and $speed

and save the contents u may get what you need..

currrently it is just saving your ControlIDs 6 + 4 respectively

HardCopy

LOL missed that, whoops, thanks thats what i needed :D
Link to comment
Share on other sites

LOL missed that, whoops, thanks thats what i needed :D

You're Welcome

Been there , done that!

Contributions: UDF _DateYearFirstChildren are like Farts, you can just about stand your own.Why am I not a Vegetarian?...Well...my ancestors didn't fight & evolve to the Top of the food chain for me to survive on Salad

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