Forum Discussion

Rob_Dobrzycki_3's avatar
Rob_Dobrzycki_3
Icon for Nimbostratus rankNimbostratus
Jun 11, 2018

simple if statement issue

Hi, I am trying to use simple comparison:

 

set nullindex 1

 

if{($nullindex>-1)}{ log local1. "test" }

 

This what I see in a log: invalid command name "if{(1>-1)}{" while executing "if{($nullindex>-1)}{"

 

Please, help

 

  • JG's avatar
    JG
    Icon for Cumulonimbus rankCumulonimbus
    set nullindex 1
    if { $nullindex > -1 } {
        log local1. "test"
    } 
    

    or if you insist on using parenthesis:

    set nullindex 1
    if { ($nullindex > -1) } {
        log local1. "test"
    }
    
  • The issue is it tries to evaluate command

    if{(1>-1)}{
    instead of
    if
    because there is no space after
    if

    And there is also a missing space after the closing curly bracket!