Jump to content
Sign in to follow this  
Folker

Database App

Recommended Posts

Folker

Hey,

I was wondering whether i could create a application that can read data from a ini and display it onscreen - and then in the menu, say, edit that ini or create a new one?

Thanks,

Folker.

Share this post


Link to post
Share on other sites
Folker

IniRead() and IniWrite() should do it.

Could you provide an example of where INIRead() and Iniwrite() are used?

Thanks,

Folker.

Share this post


Link to post
Share on other sites
Pain

Did you even bother to click on the links?

IniWrite:

If file does not exist, it is created.

This one will create a ini file with the name myfile.ini in C:\Temp\ and write some data to it.

IniWrite("C:\Temp\myfile.ini", "section2", "key", "this is a new value")

Share this post


Link to post
Share on other sites
Folker

Did you even bother to click on the links?

IniWrite:

This one will create a ini file with the name myfile.ini in C:\Temp\ and write some data to it.

IniWrite("C:\Temp\myfile.ini", "section2", "key", "this is a new value")
Ok, sorry.

I have made the ini file and want to load it from a FileOpenDialog command, so i open it, but now i want to see the ini file, i tried this:

$label = IniRead("" & $open,"SECTION1","name")

and

$label = IniRead( $open,"SECTION1","name")

and

$label = IniRead(& $open,"SECTION1","name")

but they all gave me errors..

how would i click the open button and then it displays the text on the gui, in say, a label?

Thanks,

Folker.

Share this post


Link to post
Share on other sites
spudw2k

To modify a control (apply data to it) use the GUICtrlSetData Func. Check the helpfile.

;$label = GUICtrlCreateLabel......
GUICtrlSetData($label,"message here")
Edited by spudw2k

Share this post


Link to post
Share on other sites
Pain

#include <GUIConstants.au3>

GUICreate("") 

$select = GUICtrlCreateButton("Open file", 50, 50)
$label = GUICtrlCreateLabel("test", 150, 100)
GUISetState (@SW_SHOW)

While 1
    $msg = GUIGetMsg()
    
    If $msg = $select Then 
        $file = FileOpenDialog("Select a file.", @DesktopDir & "\", "INI (*.ini)")
        $data = IniRead($file, "section2", "key", "NotFound"); section and key have to be predefined.
        GUICtrlSetData($label, $data)
    EndIf   
    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
Wend

Share this post


Link to post
Share on other sites
Folker

#include <GUIConstants.au3>

GUICreate("") 

$select = GUICtrlCreateButton("Open file", 50, 50)
$label = GUICtrlCreateLabel("test", 150, 100)
GUISetState (@SW_SHOW)

While 1
    $msg = GUIGetMsg()
    
    If $msg = $select Then 
        $file = FileOpenDialog("Select a file.", @DesktopDir & "\", "INI (*.ini)")
        $data = IniRead($file, "section2", "key", "NotFound"); section and key have to be predefined.
        GUICtrlSetData($label, $data)
    EndIf   
    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
Wend
I do this, but it displays NotFound from the $data command in the gui. i want it to display the data from the ini file.

Thanks,

Folker.

Share this post


Link to post
Share on other sites
Pain

; section and key have to be predefined.

Make sure the section name and key are correct.

[sectionName]

Key=Value

Share this post


Link to post
Share on other sites
Folker

Make sure the section name and key are correct.

[sectionName]

Key=Value

Im trying to load it so that i can open one ini file and it displays the data, and then i can load another INI file and it will display diffrent data.

Say im loading:

test1.ini

and

test2.ini

i want to load test1 first using the opendialog so it displays say, hello (predefined in the ini already created) and then use opendialog again to open test2, which would say, hey! (also predefined in a diffrent ini file.)

is there a way to do this?

Edited by Folker

Share this post


Link to post
Share on other sites
Pain

You got the example above.

My inifile:

[Message]
first=hey

The iniread part:

$data = IniRead($file, "Message", "first", "NotFound")

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.