Sign in to follow this  
Followers 0
diikee

if/elseif function

6 posts in this topic

#include <Process.au3>
#include <File.au3>
#include <IE.au3>
Opt("WinTitleMatchMode",3)

test()

func test()
$title = WinGetTitle("[active]")
ConsoleWrite($title & @CRLF)

$x = "755 settings"
$y = "712D settings"
$z = "852 settings"
$w = "855 settings"
if string($title) = $x Or $w then
 consolewrite("got here" & CRLF)
elseif string($title) = $y Or $z then
 consolewrite("got there" & CRLF)
else
 consolewrite("Try again" & CRLF)
end func

console output:

712 settings

got here

why did it print got here and not there??

wintitlematchmode is set to 3 which should be exact match...

Share this post


Link to post
Share on other sites



#include <Process.au3>
#include <File.au3>
#include <IE.au3>
Opt("WinTitleMatchMode",3)

test()

func test()
$title = WinGetTitle("[active]")
ConsoleWrite($title & @CRLF)

$x = "755 settings"
$y = "712D settings"
$z = "852 settings"
$w = "855 settings"
if string($title) = $x Or $w then
consolewrite("got here" & CRLF)
elseif string($title) = $y Or $z then
consolewrite("got there" & CRLF)
else
consolewrite("Try again" & CRLF)
EndIf; <- this is what you were missing.
end func

Share this post


Link to post
Share on other sites

CRLF should be @CRLF

end func should be EndFunc

@OP,

copy/paste semi working code to the forum :-)


[size="1"][font="Arial"].[u].[/u][/font][/size]

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

No, it's not, run the modified script and didn't work.

I need a way to match the entire title string and not partial.

- right now it's printing in comparison to the first 7xx instead of 712

#include <Process.au3>
#include <File.au3>
#include <IE.au3>
Opt("WinTitleMatchMode",3)

test()

func test()
$title = WinGetTitle("[active]")
ConsoleWrite($title & @CRLF)

$x = "755 settings"
$y = "712D settings"
$z = "852 settings"
$w = "855 settings"
if string($title) = $x Or $w then
consolewrite("got here" & @CRLF)
elseif string($title) = $y Or $z then
consolewrite("got there" & @CRLF)
else
consolewrite("Try again" & CRLF)
EndIf; <- this is what you were missing.
endfunc
Edited by diikee

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

This is your error:

elseif string($title) = $y Or $z then

I guess it should be

elseif string($title) = $y Or string($title) = $z then

In the first form that statement was always true since $z has a value.

EDIT: the same thing with:

if string($title) = $x Or $w then

if string($title) = $x Or string($title) = $w then
Edited by enaiman

SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script

wannabe "Unbeatable" Tic-Tac-Toe

Paper-Scissor-Rock ... try to beat it anyway :)

Share this post


Link to post
Share on other sites

WinGetTitle returns a string, so no need to convert the var $title to a string and you might want double equal signs for case sensitive matching - or maybe not :-)

Opt("WinTitleMatchMode", 3)

test()

Func test()
 $title = WinGetTitle("[active]")
 ConsoleWrite($title & @CRLF)

 $x = "755 settings"
 $y = "712D settings"
 $z = "852 settings"
 $w = "855 settings"
 If $title == $x Or $title == $w Then
  ConsoleWrite("got here" & @CRLF)
 ElseIf $title == $y Or $title == $z Then
  ConsoleWrite("got there" & @CRLF)
 Else
  ConsoleWrite("Try again" & @CRLF)
 EndIf
EndFunc   ;==>test


[size="1"][font="Arial"].[u].[/u][/font][/size]

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