Automic Workload Automation

Expand all | Collapse all

how to call Multiple If-Else conditions

  • 1.  how to call Multiple If-Else conditions

    Posted 04-12-2019 10:01 AM

    Hi Team ,

     

    We do have a scenario where where Multiple If conditions to be called in Pre process tab of a unix Job .Can i know how we can call them.

     

    As of now I know how to make a Single If -else condition



  • 2.  Re: how to call Multiple If-Else conditions

    Posted 04-17-2019 05:14 AM

    Hi you can simply net them:

     

    :SET &COLOR#= "green"
    :SET &FRUIT# = "kiwi"
    ! green kiwi, cucumber
    ! yellow banana, lemon
    !
    :PRINT "IF Example ================="
    :IF &COLOR# = "green"
    :  PRINT "color is green!"
    :  IF &FRUIT# = "kiwi"
    :    PRINT "fruit is kiwi!"
    :  ELSE
    :    PRINT "fruit is not kiwi!"
    :  ENDIF
    :ELSE
    :  PRINT "color is not green!"
    :  IF &FRUIT# = "banana"
    :    PRINT "fruit is kiwi!"
    :  ELSE
    :    PRINT "fruit is not banana!"
    :  ENDIF
    :ENDIF

     

    :PRINT ""
    !
    ! =======
    :PRINT "SWITCH Example ================="
    !
    :SWITCH &COLOR#
    :  CASE "green"
    :  PRINT "Color: green"
    :  SWITCH &FRUIT#
    :    CASE "kiwi"
    :    PRINT "Fruit: kiwi"
    :    CASE "cucumber"
    :    PRINT "Fruit: cucumber"
    :    OTHER
    :    PRINT "other fruit than kiwi or cucumber"
    :  ENDSWITCH
    :  CASE "yellow"
    :  PRINT "Color: yellow"
    :  SWITCH &FRUIT#
    :    CASE "banana"
    :    PRINT "Fruit: banana"
    :    CASE "lemon"
    :    PRINT "Fruit: lemon"
    :    OTHER
    :    PRINT "other fruit than banana or lemon"
    :  ENDSWITCH
    :  OTHER
    :  PRINT "other color than green or yellow"
    :ENDSWITCH

     

     

    2019-04-17 11:12:55 - U00020408 IF Example =================
    2019-04-17 11:12:55 - U00020408 color is green!
    2019-04-17 11:12:55 - U00020408 fruit is kiwi!
    2019-04-17 11:12:55 - U00020408
    2019-04-17 11:12:55 - U00020408 SWITCH Example =================
    2019-04-17 11:12:55 - U00020408 Color: green
    2019-04-17 11:12:55 - U00020408 Fruit: kiwi

     

    cheers, Wolfgang



  • 3.  Re: how to call Multiple If-Else conditions

    Posted 04-22-2019 09:24 AM

    Thanks Wolfgang..