edumanilha Posted March 29, 2020 Share Posted March 29, 2020 (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 March 29, 2020 by edumanilha Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 29, 2020 Moderators Share Posted March 29, 2020 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 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 columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
edumanilha Posted March 29, 2020 Author Share Posted March 29, 2020 (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 March 29, 2020 by edumanilha correction Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 29, 2020 Moderators Share Posted March 29, 2020 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 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 columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
edumanilha Posted March 29, 2020 Author Share Posted March 29, 2020 (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 March 29, 2020 by edumanilha typo Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now