value is not applied to the txtjoin function

  • Hi,

    I am using the txtjoin function.

    The description of the txtjoin function is as follows:

    It is explained that you can use value for the parameters "var1, var2, ...".


    I coded it like this:

    Code
    txtjoin(layer[button_test2].html, '|', '0', '0', '0', '0');


    or

    Code
    txtjoin(layer[button_test2].html, '|', 0, 0, 0, 0);


    Here is the result:


    In the result, value is not applied and only the separator is displayed.


    The functionality of the txtjoin function should be updated or the documentation should be modified.

  • @ oi, you're right, thanks... this is a bug!

    txtjoin(test1, '|', 'a', 'b', 'c', 'd');
    debugvar(test1);
    // DEBUG: |||

    txtsplit('a|b|c|d', '|', test2);
    debugvar(test2);
    // DEBUG: test2=[Array] type=object
    // DEBUG: test2.count=[4] type=number

    txtjoin(test3, '/', test2);
    // --> javascript error in console!
    txtjoin(test3, '/', get(test2));
    // --> javascript error in console!

    *question* *pinch* *squint*

  • Hi,

    right, this is an error in the documentation - only variables are currently supported.

    But with the next releases (1.21 and up) values will be supported too.


    Zitat

    txtjoin(test3, '/', test2);
    // --> javascript error in console!

    Right, this is a bug - the txtsplit actions generates a 'krpano array' (an array with objects as items), but the txtjoin action takes a 'value array' (a normal Javascript array with values as items) as input. And when the parameters is not such value array, a Javascript error happens.

    With the next releases there will be an additional validity check for the parameters, and the txtsplit action will be probably changed to return a 'value array'.

    Best regards,
    Klaus

  • hm...that would break a lot of code and cause quite some work here ...

    Okay, was just thinking about it, haven't checked the usage yet, it just seems the array output is only very rarely used.

    wouldn't it be better to keep compatibilty somehow?

    Currently txtsplit and txtjoin are using incompatible array types. That means at least one action should get changed and the usage of value array would be technically the better one.

    But keeping the txtsplit unchanged and changing the txtjoin action that it automatically supports both array types would be also an option.

    Best regards,
    Klaus

Jetzt mitmachen!

Sie haben noch kein Benutzerkonto auf unserer Seite? Registrieren Sie sich kostenlos und nehmen Sie an unserer Community teil!