Forum Discussion

Joel_42834's avatar
Joel_42834
Icon for Nimbostratus rankNimbostratus
May 17, 2014

iCall Script Argument Passing

How does an iCall script access arguments that have been passed to it from a periodic handler?

 

  • Okay, so let's say you have a periodic handler defined with arguments. Example:

     

     

    sys icall handler periodic testlogger {
        arguments {
            {
                name test
                value blah
            }
            {
                name foo
                value bar
            }
        }
        interval 30
        script testlogger
    }
    

     

    To access those arguments within your script, you'd use the EVENT::context command inside a foreach loop. Something like this:

     

     

    sys icall script /Common/testlogger {
        app-service none
        definition {
            foreach var { test foo } {
                set $var $EVENT::context($var)
            } 
            tmsh::log "testing: ${test} - ${foo}"
        }
        description none
        events none
    }
    

     

2 Replies

  • Okay, so let's say you have a periodic handler defined with arguments. Example:

     

     

    sys icall handler periodic testlogger {
        arguments {
            {
                name test
                value blah
            }
            {
                name foo
                value bar
            }
        }
        interval 30
        script testlogger
    }
    

     

    To access those arguments within your script, you'd use the EVENT::context command inside a foreach loop. Something like this:

     

     

    sys icall script /Common/testlogger {
        app-service none
        definition {
            foreach var { test foo } {
                set $var $EVENT::context($var)
            } 
            tmsh::log "testing: ${test} - ${foo}"
        }
        description none
        events none
    }