You are not logged in.

di0deman

Beginner

  • "di0deman" started this thread

Posts: 12

Location: Republic of Korea

  • Send private message

1

Monday, February 8th 2021, 2:03am

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:

Source code

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



or

Source code

1
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.

2

Monday, February 8th 2021, 8:41am

@ 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*

This post has been edited 9 times, last edit by "indexofrefraction" (Feb 8th 2021, 9:07am)


3

Monday, February 8th 2021, 10:59am

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.


Quoted

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

4

Monday, February 8th 2021, 11:19am

hi klaus,

Quoted

and the txtsplit action will be probably changed to return a 'value array'.

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

wouldn't it be better to keep compatibilty somehow?

5

Monday, February 8th 2021, 11:47am

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