Jump to content
SergeiK

If multiple conditions Then

Recommended Posts

SergeiK

Hello Everyone,

Is it possible to get shorter multiple condition expressions avoiding operator OR? for instance If @OSVersion In (Win_10, Win_7, Win8) Then. I got used to it in t-sql. Thank you.

 

Share this post


Link to post
Share on other sites
water

Please have a look at Switch or Select in the help file.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2018-09-01 - Version 1.3.4.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites
SergeiK
19 hours ago, mikell said:

:)

If StringRegExp(@OSVersion, '(?i)Win_(10|7|8)') Then ...

 

  Regular Expressions are very cool! :) Thanks a lot. But I thought it can be more easier. It will do anyway!

Share this post


Link to post
Share on other sites
mikell

Well, I'm pretty surprised that iamtheky didn't suggest

If StringInStr("Win_10,Win_7,Win8", @OSVersion) Then ...

which means the same but avoids regex  :)

Share this post


Link to post
Share on other sites
Chimp

:geek:

#include <SQLite.au3>

Local $aResult, $iRows, $iColumns, $iRval

_SQLite_Startup()
_SQLite_Open() ; Open a :memory: database

If _IN(@OSVersion, "WIN_10,WIN_7,WIN_8") Then MsgBox(0, '', "Yes")

_SQLite_Close()
_SQLite_Shutdown()

Func _IN($1, $2) ; returns True or False
    $2 = StringReplace($2, ",", "','")
    ; Query
    $iRval = _SQLite_GetTable(-1, "SELECT '" & $1 & "' IN ('" & $2 & "') ;", $aResult, $iRows, $iColumns)
    Return $aResult[2] <> 0
EndFunc   ;==>_IN

 


small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....

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

  • Similar Content

    • Fr33b0w
      By Fr33b0w
      Func z009() If FileExists("search\009\009.au3") Then #include <search\009\009.au3> EndIf EndFunc This wont work...  Is there any workarround for this or I should do it in a different way?
       
    • Masum
      By Masum
      Hi all,
      I'm going crazy while I try and work out why a fairly simply if condition isn't working. I will try and explain it clearly, in the hope someone can find out the cause. The portion of the script for these if conditions is copied in below. The first PixelGetColor func is denoted in Screenshot 1, the RED dot signifies where the color is extracted from. The second PixelGetColor func is denoted in Screenshot 2, the YELLOW dot signifies where the color is extracted from. The script is tested for 3 scenarios, where 1. no resource is found (Screenshot 1), 2. multiple resources are found (Screenshot 2), and 3. only 1 resource is found (Screenshot 3). This application is being run via RDP hence I can't access the controls, and therefore relying on the pixel colours. The issue is, for all three scenarios, only the first If condition's first result is shown, even though the actual program shows the 3 screenshots for each of the three scenarios. Any ideas where I'm going wrong?
      If PixelGetColor(697, 446, 0xF0F0F0) Then ;If resource is not found, cancel out
              Sleep(200)
              MsgBox(64, 'Error', 'Resource is not found, therefore this pool will not be saved and will cancel out. Click OK to continue.')
              _Excel_RangeWrite($oWorkbook, 'CHFT Pools & RTE Rules', 'Fail', 'I' & $ColumnIRow)
              _Excel_RangeWrite($oWorkbook, 'CHFT Pools & RTE Rules', 'Resource not found. ' & $Notes, 'J' & $ColumnIRow)
              Sleep(500)
              WinActivate('Scheduling Help')
              Sleep(500)
              Send('{ENTER}') ;Click OK
              Sleep(500)
              Send('{SHIFTDOWN}{TAB}{SHIFTUP}{ENTER}') ;Click Cancel
              Sleep(500)
              Send('{SHIFTDOWN}{TAB}{TAB}{TAB}{TAB}{SHIFTUP}{ENTER}') ;Click Close
              Sleep(500)
              WinActivate('Scheduling: DB Flex Rule Tool - Inbox Pool Routing')
              Sleep(500)
              Send('{TAB}{ENTER}') ;Click Yes
              Sleep(500)
              WinActivate('Rules for Pool')
              Sleep(500)
              Send('{TAB}{TAB}{TAB}{ENTER}') ;Click Cancel
              Sleep(500)
              MouseClick('Primary', 1259, 653, 1) ;Click Cancel
          Else
              Send('{TAB}{TAB}{DOWN}') ;Find resource
              If PixelGetColor(725, 383, 0x3399FF) Then ;If there are multiple resources, cancel out
                  Sleep(200)
                  MsgBox(64, 'Error', 'There are multiple resources, therefore this pool will not be saved and will cancel out. Click OK to continue.')
                  _Excel_RangeWrite($oWorkbook, 'CHFT Pools & RTE Rules', 'Redo', 'I' & $ColumnIRow)
                  _Excel_RangeWrite($oWorkbook, 'CHFT Pools & RTE Rules', 'Multiple resources. ' & $Notes, 'J' & $ColumnIRow)
                  Sleep(500)
                  WinActivate('Scheduling Help')
                  Sleep(500)
                  Send('{TAB}{TAB}{ENTER}') ;Click Cancel
                  Sleep(500)
                  Send('{SHIFTDOWN}{TAB}{TAB}{TAB}{TAB}{SHIFTUP}{ENTER}') ;Click Close
                  Sleep(500)
                  WinActivate('Scheduling: DB Flex Rule Tool - Inbox Pool Routing')
                  Sleep(500)
                  Send('{TAB}{ENTER}') ;Click Yes
                  Sleep(500)
                  WinActivate('Rules for Pool')
                  Sleep(500)
                  Send('{TAB}{TAB}{TAB}{ENTER}') ;Click Cancel
                  Sleep(500)
                  MouseClick('Primary', 1259, 653, 1) ;Click Cancel
              Else ;Select the resource
                  Send('{ENTER}') ;Select Order Physician
                  MsgBox(0, '', 'save button clicks now')
                  _Excel_RangeWrite($oWorkbook, 'CHFT Pools & RTE Rules', 'Complete', 'I' & $ColumnIRow)
                  _Excel_RangeWrite($oWorkbook, 'CHFT Pools & RTE Rules', 'Success. ' & $Notes, 'J' & $ColumnIRow)
                  ;Send('{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{ENTER}') ;Click Save
              EndIf
          EndIf

×