Sign in to follow this  
Followers 0
lawonama

Ini read and write??

11 posts in this topic

I have the following code:

$msg = GUIGetMsg()
Switch $msg
Case $GUI_EVENT_CLOSE
        Exit
Case $Button
        IniWrite("C:\TKeybind\settings.ini", "Settings", "1", $text1)
Case $Load
        IniRead("C:\TKeybind\settings.ini", "Settings", "1", $text1)
EndSwitch
WEnd

But it wont work :mellow:

Share this post


Link to post
Share on other sites



lawonama,

But it wont work

What does not work? Are you creating the ini file? Do you get the default value when loading? :mellow:

More info please! :)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______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

What is $text1?

Is it a GUI Input control? What are you doing with the read? You're suppose to get a return (and if it can't read it, it'll return whatever $text1 is.)

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

$text1 = GuiCtrlCreateInput("", 10, 10, 290, 20)

I have this. Im writing in the input for example : Hello.

I press SAVE, and when I press LOAD it wont work. It doesn't make a .ini file. I tried to make the .ini file my self. But still it wont write inside.

Its supposed to: Someone writes a text in $text1.

When he presses the save button, it saves to the .ini file.

When he presses the load button, it loads from the .ini file.

Edited by lawonama

Share this post


Link to post
Share on other sites

lawonama,

I suspect it is your OS not allowing you to write to the C:\ drive. :mellow:

Try changing the file path and see if you can write it elsewhere - best practice suggests that "C:\Users\your_name\AppData" is a good place. :)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______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

Use GuiCtrlRead($text1) instead of $text1.


Programming today is a race between software engineers striving to
build bigger and better idiot-proof programs, and the Universe
trying to produce bigger and better idiots.
So far, the Universe is winning.

Share this post


Link to post
Share on other sites

You are right! It works.. but I wrote at the box : "Hello"..

But in the Settings.ini I see:

[settings]

1=5

I tried also : "asdsada"

and its still

[settings]

1=5

Anyone knows how to fix?

Share this post


Link to post
Share on other sites

lawonama,

Glad my suggestion worked. :mellow:

funkey has given you the answer to your new problem just above. You are currently saving the ControlID of the input, not the content. :)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______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

Hmm yes, it worked :mellow:. But when I press load.. I dont see the :"Hello" in the box. It wont come there :)

Share this post


Link to post
Share on other sites

Try something like

Case $Load
        $sSettings = IniRead("C:\TKeybind\settings.ini", "Settings", "1", "0")
        GUICtrlSetData($text1, $sSettings)

Share this post


Link to post
Share on other sites

Thanks! It worked. This topic can be closes.

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