Blockly: {textVariable} dosent work?

The following script is just an example to explain my problem:
image
translated to Javascript:

var _7BtextVariable_7D, Text01;


events.sendCommand('VI_TEST_02', 'abcdefg');
_7BtextVariable_7D = itemRegistry.getItem('VI_TEST_02').getState();
Text01 = _7BtextVariable_7D.charAt(2);
events.sendCommand('VI_TEST_01', Text01);

When running it, I get this error:

2023-02-04 21:45:01.365 [ERROR] [internal.handler.ScriptActionHandler] - Script execution of rule with UID 'Spotpriser2' failed: TypeError: _7BtextVariable_7D.charAt is not a function in <eval> at line number 6

I expected Text01 to become c.

Can someone help me?

/Torben

The problem is that it returns a State which is an object and not what you would expect it to be: a string.

Here is how you could view that (see the little inline script)

The way you can make the state to become a string with a little trick by adding a “” to it which “forces” it to become a string.

The good news is, though, that with 4.0 and the introduction with the new jsscripting library in the background (based on GraalVM instead of Nashorn) automatically stringifies it.

Thanks a lot Stefan for takeing yor time - that did the job.
I took me a litle time to build:
image

The block is not immediately visible on the list
Thanks for Blockly, it is fantastic for makeing rules/scripts when you don’t have much knowledge of programming.
In my case, you can call it “tool for a fool”
/Torben