Issue (bug?) with SET action

  • According to the docs:

    Quote

    set(variable, value)

    Set the given 'variable' to the given 'value'.

    Note - when the name of "value" is a variable, it will be NOT resolved automatically!
    To get the content of a variable the get(variable) function need to be used!


    Well... not exactly, and that can cause lots of wasted time when, like me, you forget the above note. Consider:


    Notice: Whether you set tmp to "test" or "get(test)" it traces to the same value, but when you use that value you get very different results -- but not always. The results are the same in string concatenation, for instance (txtadd). How does that make sense?

    Klaus -- Since when you do and don't have to use get() is... confusing you can understand how this can easily be missed. Since I seemed to be getting the right result without get() debugging was quite frustrating. Shouldn't set(tmp, test) result in tmp==null or tmp=='test' instead?

    Going forward, would it be possible for this to be more like javascript throughout? Just use "var" instead of "get(var)" or set() for that matter?

  • Hi,

    that's not a bug, that's the current intended behavior.

    Some actions are resolving variables to their values by their own and some others are requiring the usage of get() for this. But what is happening should be documented at each action (if not - please tell me and I will update the documentation).

    The reason for this behavior is partially historical and also simplify. The actions/variable system doesn't have a type definition, there is no difference between a variable and a string. The quote characters are only for quoting and not to define if a value is a string.

    But I agree that this can be confusing and I'm already planing a different system and behavior (a more classic one). But as any changes here would brake existing code, that's more something for a 'krpano 2.0' version. And even then, there will be still a compatibility mode to support the old and the new system to keep old code working.

    Best regards,
    Klaus

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!