Menu

sys.isVariableDefined

Help
Anonymous
2011-11-11
2012-09-04
  • Anonymous

    Anonymous - 2011-11-11

    hello

    Is there a way to test if a variable is defined in a function to avoid the bug
    in sys.isVariableDefined ?

    Thank's

     
  • Alex Wajda

    Alex Wajda - 2011-11-17

    not sure I understand what bug you are talking about. sys.isVariableDefined
    does exactly what it's meant to do. At least it is so in WH 2.1

     
  • Anonymous

    Anonymous - 2011-11-18

    sorry I was not very clear...

    from a function I was trying to test a variable defined outside the function
    and not passed as parameter with the 2.0 version, but it wasn't working.

     
  • Alex Wajda

    Alex Wajda - 2011-11-18

    yes, in WH 2.0 there are some troubles with accessing outer context from
    inside the function. That's because in WH 2.0 there is no true hierarchical
    context. If I remember correctly in WH 2.0 there is a hack for this issue -
    from a function you may use "caller." prefix to access the outer context
    variable. Consider the example below.

    <var-def name="x"/>
    <function name="f">
        <var name="caller.x"/>
        <function name="k">
            <var name="caller.caller.x"/>
        </function>
        <call name="k"/> <!-- OK --> 
    </function>
    <call name="f"/>
    <call name="k"/> <!-- THIS WILL BREAK as from inside function K variable X will be accessible as "caller.x" instead of "caller.caller.x" -->
    
     

Log in to post a comment.