Jump to content
Sign in to follow this  
smokeys13

If Not and If $var <> stuff not working

Recommended Posts

smokeys13

Hi,

I'm trying to loop through the keys under the specified section of my .ini file.

"config.ini"

[step 1]
down=3
char=m

"test.au3"

$step1 = IniReadSection("config.ini","step 1")

$i = 1
$keys = 0


While $step1[$i][0] + 1 == 1
    $keys = $keys + 1
    MsgBox(0,"keys",$keys)
    $i = $i + 1
WEnd


MsgBox(1,"my title",$keys)

As you can tell this is basically a way for me to decipher how many keys are stored under the specified section.

After the second msgbox has appeared displaying "2" the script ends saying " WEnd^ ERROR ".

I therefore decided to put "If $step1[$i][0] + 1 <> 1 Then ExitLoop" and "If Not $step1[$i][0] + 1 == 1 Then ExitLoop" before WEnd but neither validated.

Any help would be greatly appreciated

Share this post


Link to post
Share on other sites
whim

Unless i misunderstood the help file ("Function IniReadSection: The number of elements returned will be in $result[0][0]. ")

your array $step[0][0] should contain the number of keys in your ini section

hth,

whim

Share this post


Link to post
Share on other sites
Yashied

Share this post


Link to post
Share on other sites
smokeys13

Thanks for your prompt replies, I'm going to just use $step1[0][0] - thanks for pointing that out to me, I feel a bit stupid for not reading further down the help file now though... :D

All is now working as planned, thanks again for your help!

Share this post


Link to post
Share on other sites
JohnOne

$step1 = IniReadSection("config.ini","step 1")
If Not @error Then Msgbox(0,"Return", "Amount of keys =" & $step1[0][0])

EDIT: sorry, got distracted and didnt notice you had your answer.

Edited by JohnOne

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Share this post


Link to post
Share on other sites
smokeys13

$step1 = IniReadSection("config.ini","step 1")
If Not @error Then Msgbox(0,"Return", "Amount of keys =" & $step1[0][0])

EDIT: sorry, got distracted and didnt notice you had your answer.

No problems, thanks for replying anyway. In fact, your reply has brought "@error" to my attention so thank you for 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.