Sign in to follow this  
Followers 0
James

Reading ini then set what it says

10 posts in this topic

#1 ·  Posted (edited)

OK, so my last topic wasn't my last because of this.

When you chose a menu colour, it writes it to a .ini :

[MenuColour]
NewColour=Blue

Right?

Now what I need is to make a function which will read the value of the key and set the colour of the menu.

I tried this:

Func ReadMenuColor()
    $DefMenu = IniReadSection("Settings.ini", "MenuColour")
    If StringInStr($DefMenu), "Default") Then
        SetDefaultMenuColors()
    EndIf
EndFunc

But it didn't work.

Secure

Edited by Secure_ICT

Share this post


Link to post
Share on other sites



$DefMenu = IniReadSection("Settings.ini", "MenuColour")

returns an array

use iniread()

****************

also it wont work because the value is "blue" not "default"

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

this should give an error

$DefMenu = IniRead("Settings.ini", "MenuColour", "NewColour")

it should have 4 values

$DefMenu = IniRead("Settings.ini", "MenuColour", "NewColour", "Default")

read the help file

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

Func ReadMenuColor()
    If StringInStr(IniRead("Settings.ini", "MenuColour", "NewColour",""), "Blue") Then
        SetBlueMenuColors()
    EndIf
EndFunc

why are you using stringinstr? why not just check if it equals blue

Share this post


Link to post
Share on other sites

if you are going to shorten it then..

Func ReadMenuColor()
    If StringInStr(IniRead("Settings.ini", "MenuColour", "NewColour",""), "Blue") Then SetBlueMenuColors()
EndFunc

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

For like Multiple colors you can create your function and implement parameters to it.

Global $colors[5] = ["Red","Blue","Yellow","Green","Purple","Orange"]
Func ReadMenuColor()
    For $i = 0 To UBound($colors) - 1
    If IniRead("Settings.ini", "MenuColour", "NewColour","") = $colors[$i] Then SetMenuColors($colors[$i])
    Next
EndFunc

or you can throw in an exitloop but its only going to equal one color so keeping it to a short one liner i assume would be fine

Share this post


Link to post
Share on other sites

For like Multiple colors you can create your function and implement parameters to it.

Global $colors[5] = ["Red","Blue","Yellow","Green","Purple","Orange"]
Func ReadMenuColor()
    For $i = 0 To UBound($colors) - 1
    If IniRead("Settings.ini", "MenuColour", "NewColour","") = $colors[$i] Then SetMenuColors($colors[$i])
    Next
EndFunc
 oÝ÷ Úò¢çØk£§jw±Ùh¢î¶+l¢yr§Úªæ¥¢w¢Z+²z§+m¡«!¢»hébêâjË.ì(ºW[yø§{ú®¢×¢Á«-)äx-ëìÊ+lyé¬Ê­é)à~éܶ*'±ú+y§!rh­'­
çÚº[Lz{¢Z+±'­[1éî
h®Ç­srl¶Þ¶¢Z+½©nz¶­êí©íéÚ쨺¯x×°
hº

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

i was thinking the same way

; it seems you are making functions for each color

SetDefaultMenuColors()

SetBlueMenuColors()

etc.........

why not store the color value rather than the name, you have

NewColour=Blue

just make that the actual color value

NewColour=0x0fff?? ; (for Blue)

Then

Func ReadMenuColor()
    $DefMenu = IniRead("Settings.ini", "MenuColour", "NewColour", "Default")
    If StringInStr($DefMenu), "Default") Then
        SetDefaultMenuColors()
    Else
        SetMenuColors($DefMenu) ; pass the color value to the function
    EndIf
EndFunc

8)

Lol yeah I was thinking that but I was to lazy to go look up the Hex Values so I decided names were good enough :P

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