Array With Delimiter From Variable


Is there any way to count (or set or read) a variable array, with a custom delimiter defined from a variable?

I thought I had testen (and succeeded in) this before, but when searching my macros now I can't find any example of it, so I must have imagined it.

Setting it up as %Variable%local_array[0]local_delimiter% does not work, as it is local_delimiter (not the content of the variable) that is interpreted as the delimiter ('correctly' returning 1 as the result ).

Setting it up as %Variable%local_array[0]%Variable%local_delimiter%% also does not work, as it gets interpreted as %Variable%local_array[0]% followed by Variable followed by %local_delimiter% followed by % ('correctly' returning a result of 1Variable;% (took me a while to wrap my head around what was going on with this one!)).

Anyone having any idea of how/if this can be done?

Calculate Array Size Based of Custom Delimiter from Variable.kmmacros (2.9 KB) (v11.0.2)

Try this:

1 Like

This works! Thank you so much!

I had the feeling a Filter action to Process Tokens could be part of the solution, but I am never fully able to grasp the logic of where and when it's needed.

Something else I am not able to fully grasp is how you've divided out the percentage symbols to make this work. The way I am reading it out is like this:

But I know this must be wrong as the extra % makes no sense (and it does not work without it). In the interest of learning I'd love to hear your logic behind how this is set up @kcwhat, and also if you have any thought about when and where the Filter action to Process Tokens is needed. Also if anyone else kan shed light on this, I am more than interested in any thoughts!

You're welcome. Glad it worked and I'm sure there are other ways to solve it. I had a similar situation and 2 posts, from @peternlewis, helped me. I bookmarked them for future reference. Both are from the same topic/thread and I'm sure I read them 20 times. Some days I understood and some I didn't. Today, I did and tomorrow I won't. :slight_smile:

In any event, bookmark the below:

Take care,

1 Like

Those posts are now bookmarked, and I'll go through them carefully tomorrow, after a nights sleep as I quickly felt it not sinking in past my tired eyes here right now. But I think Peters defining it as the Filter action processes the tokens a second time, whats left of the tokens after the first time that is, can be the key for me to make logic of this! Thank you so much for pointing me to this!

1 Like