Jump to content
Sign in to follow this  
stuka

removed

Recommended Posts

stuka

.

Edited by stuka

Share this post


Link to post
Share on other sites
Pain

Iniread doesn't return true or false (1 or 0).

If it fails it return the default value, in your case "0".

Share this post


Link to post
Share on other sites
Pain

yes but that returns the string "0", only 0 is a number that is same as false. Try If $inivar = "0" to use the returned string.

Edited by Pain

Share this post


Link to post
Share on other sites
zerobazar

Then you should test like this:

...
If $inivar = "0" Then
...

You see the quotes?

No problem to use FileOpenDialog to pick the file you want to try/read.

Best Regards.

Oops. Pain has been too fast!

Edited by zerobazar

Share this post


Link to post
Share on other sites
Bert

I was trying to use FileOpenDialog to tell IniRead which file to read... maybe wrong usage. But is there another better way to do this?

$key = iniread(@scriptdir&"/setting.ini", "section", "key", "default")

As I said in the first post. You don't use FileOpenDialog with iniread. Just use iniread to get your key.

Share this post


Link to post
Share on other sites
Bert

But I'm using FileOpenDialog to select which inf file I would like IniRead to read...

So that a user can browse for any inf files and choose it...i'm not using it for an .ini settings file...

I'm sorry, I misunderstood. OK, I tried the following to see if this would work, and it worked fine for me. I put in a msgbox to see if FileOpenDialog would show the path to the inf file first.

$openvar = FileOpenDialog("test", @HomeDrive, "Inf File (*.inf)", 1)
$inivar1 = IniRead($openvar, "autorun", "open", "0")
MsgBox(0, $inivar1, $openvar);returned path and the key. I made a inf file and it found it.
If @error Then
    Exit
Else
$inivar = IniRead($openvar, "autorun", "open", "0")
If $inivar = 0 Then
    MsgBox(4096,"","No such key")
Else
    MsgBox(4096,"","Key found!") 
EndIf
EndIf

Now, I coded my inf file like this:

[Autorun]

open=software.exe

Is your coded like this? you may want to check that.

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.