Jump to content
Sign in to follow this  
BlueScreen

IniReadSection issue

Recommended Posts

Take a look at this code

#include <GUIConstants.au3>
#include <Array.au3>
#include <Core.au3>

Dim $INIarray [3][3]

Global $Done
Global $Browse
    
DrawGui ()

While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            Exit
    
        Case $msg = $Browse
            $fileInput = FileOpenDialog("", "c:\", "txt (*.txt)", 1+4)
                
        Case $msg = $Done
            
            $INIarray=IniReadSection ("x.ini", "y")
            $Num=$INIarray[0][0]
            exit
    EndSelect
WEnd

Func DrawGui ()
    
    GUICreate("",350,270)
    $Browse=GUICtrlCreateButton ("Browse",137,155,75,25)
    $Done=GUICtrlCreateButton ("Done",137,195,75,25)
    GUISetState ()
EndFunc

When I choose “Browse” and then I choose a txt file NOT from c:\, after pressing “Done”, I get an error message. Why? :o

Edited by BlueScreen

Share this post


Link to post
Share on other sites

FileOpenDialog() changes the working copy. When you subsequently try to open "x.ini", it's being searched for at @WorkingDir\x.ini when what you really mean is @ScriptDir\x.ini. The solution is to use @ScriptDir & "\x.ini" explicitly.

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  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...