Jump to content
edumanilha

Var don't work with .init [SOLVED]

Recommended Posts

Posted (edited)

Hi,

I'm trying to implement init on my script, to save some preferences...The first one was mute, but when I change the script to .init use, my var seens not working...

 

IniWrite ("Config.ini", "Effects", "Mute", "True")
            sleep(200)
            $Mute = IniRead("Config.ini", "Effects", "Mute", "")

I put the sleep cause I tried to eliminate some lag between the write and read...But thats not the problem, when I put msgbox, the var is OK...

My script only work with the basic: $Mute = False/True

Edited by edumanilha

Share this post


Link to post
Share on other sites

edumanilha,

Ini files only store strings - so you would need to convert both the stored and returned value - perhaps like this:

#include <MsgBoxConstants.au3>

$Mute = False

If $Mute = True Then
    $Mute = 1
Else
    $Mute = 0
EndIf

IniWrite ("Config.ini", "Effects", "Mute", $Mute)

Sleep(200)

$Mute = IniRead("Config.ini", "Effects", "Mute", "")

If $Mute == "1" Then
    $Mute = True
Else
    $Mute = False
EndIf

MsgBox($MB_SYSTEMMODAL, "Value", $Mute)

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

 

Share this post


Link to post
Share on other sites
Posted (edited)
5 hours ago, Melba23 said:

edumanilha,

Ini files only store strings

 

Thanks for your help! Now it works!

I did this:

On func:

IniWrite ("Config.ini", "Effects", "Mute", "1")
~;sleep(200)
~;$Mute = IniRead("Config.ini", "Effects", "Mute", "")
~;If $Mute == "1" Then $Mute = True
$Mute = True

On script start:

$Mute = IniRead("Config.ini", "Effects", "Mute", "")
If $Mute == "1" Then
        $Mute = True
Else
        $Mute = False
EndIf

For learning purposes:

Whats the diference between - $Mute = True for $Mute = "fetch value and return here" (True) ? Because when I do this, I'm not telling $Mute to accept this value?

$Mute = IniRead("Config.ini", "Effects", "Mute", "")


In my thinking the string situation is like: "read something" ($Mute = True) So I'm not "linking" the value to the var, I just read some raw text...

and I saw you kept the sleep, you think I should keep there?

Thanks again for you help!

Edited by edumanilha
correction

Share this post


Link to post
Share on other sites

edumanilha,

Sorry, but I am afraid I do not understand your question concerning the assignment of a value to the $Mute variable.

As to the Sleep - why do you need it at all? You already have $Mute set to the correct Boolean value so why go to all the trouble of re-reading it from the ini file? The Ini* functions are pretty reliable and in my experience I have never had an IniWrite that did not work (if the file has the necessary permissions set).

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

 

Share this post


Link to post
Share on other sites
Posted (edited)
17 minutes ago, Melba23 said:

edumanilha,

Sorry, but I am afraid I do not understand your question concerning the assignment of a value to the $Mute variable.

You're right...I'll put the read just in the script starting...I forgot to rip this part... The sleep was por diagnosis, but thats not the case, so I'll delete this too!

About the assignment, I'm curious about the difference between direct assignment and fetch the True/False in the file...But You said already! So nevermind! :)

Thanks for your support and time!

Edited by edumanilha
typo

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

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...