Sign in to follow this  
Followers 0
Resurrection

IniRead help please.

10 posts in this topic

What am I doing wrong?

$Server = Iniread( "AL.ini", "Server", "", "" )
if $Server = Iniread( "AL.ini", "Server", "1", "" ) Then
    Sleep(1500)
    MouseClick("left", 512, 155, 1, 2) 
ElseIf 
    $Server = Iniread( "AL.ini", "Server", "2", "" ) Then
    Sleep(1500)
    MouseClick("left", 512, 700, 1, 2)
EndIf

It only reads number 1 I really don't know why.

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Change "ElseIf" to "Else" and get rid of that "Then", or put that line just below "ElseIf" on the same line as "ElseIf". Untested.

Edited by Champak

Share this post


Link to post
Share on other sites

$Server = Iniread( "AL.ini", "Server", "", "" )
if $Server = Iniread( "AL.ini", "Server", "1", "" ) Then
    Sleep(1500)
    MouseClick("left", 512, 155, 1, 2) 
Else
    $Server = Iniread( "AL.ini", "Server", "2", "" )
    Sleep(1500)
    MouseClick("left", 512, 700, 1, 2)
EndIf

You mean like that? Cause with that it still selects number 1.

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

I believe you have the syntax wrong. You are looking for the value of what is supposed to be 1 or 2. So if I understand what you are doing, you are looking for, let's say "Dog", and if "Dog" is 1 do this, and if "Dog" is 2 do that, so you need to do this.

$Server = Iniread( "AL.ini", "Server", "Dog", "" )
  Sleep(1500)
if $Server = 1 Then
    MouseClick("left", 512, 155, 1, 2) 
Else
    MouseClick("left", 512, 700, 1, 2)
EndIf
Edited by Champak

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

That code does work for me but the problem is there are 6 servers not 2 so how can I make a different between that?

EDIT: I just saw your edit ill just go try that.

EDIT: That second code doesn't select any of them.

Edited by Resurrection

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

That's what the second example is for. So you'd do:

$Server = Iniread( "AL.ini", "Server", "Dog", "" )
  Sleep(1500)
if $Server = 1 Then
    MouseClick("left", 512, 155, 1, 2) 
ElseIf $Server = 2 Then
    MouseClick("left", 512, 700, 1, 2)
ElseIf $Server = 3 Then
    MouseClick("left", 512, 700, 1, 2)
ElseIf $Server = 4 Then
    MouseClick("left", 512, 700, 1, 2)
ElseIf $Server = 5 Then
    MouseClick("left", 512, 700, 1, 2)
ElseIf $Server = 6 Then
    MouseClick("left", 512, 700, 1, 2)
EndIf

If it is just two options you would use "Else" like the first one, if you have multiple options like you do you would use "ElseIf" like the second one and this.

Edited by Champak

Share this post


Link to post
Share on other sites

That code also doesn't work, I think the error is my ini here it is:

Username=

Password=

Server=2

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

[server]

Username=

Password=

Dog=2

Or in your case

You would look for it like

$Server = Iniread( "AL.ini", "Whatever Name", "Server", "" )

and your ini would look like

[Whatever Name]

Username=

Password=

Server=2

Edited by Champak

Share this post


Link to post
Share on other sites

It is working thank you very much.

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

That code also doesn't work, I think the error is my ini here it is:

Username=

Password=

Server=2

That's not correct INI syntax. It should be:

[Info]
Server=something
Password=something
Username=something

However, your ini doesn't have any sections. If you use this sample INI, you could use

$Server = IniRead("C:\Config.ini", "Info", "Server", "")

to get the server value.

EDIT: Heh, Champak beat me to it. Nothing to see here. Move along. >_>

Edited by phaze424

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