"\n" becomes "\\n"

  • I want to output multiline text. If I enter the text as a literal in the properties of a label, the line break is executed correctly. But if the text with the line break is in a variable \n becomes \\n. This means that the line break is no longer executed. Is this behavior intentional?
    I think it is a bug that should be corrected as soon as possible.

    Thanks a lot

  • @peter

    I guess it seems like a bug, but I'm not sure who's bug it is. The official Google Blockly does the same thing...

    0_1616508182017_Screen Shot 2021-03-22 at 7.44.10 PM.png

  • @world101
    Then M5Stack must have taken over the problem.
    I will try again with replacing "\\n" with "\n" with the appropriate text block. But still got to it because my computer had to be reinstalled. I will report back.

  • the problem is probably that the parser of the uiflow editor treats the \ character as a special character and prefixes it with another character in order to display it. The effect of this is that only one character should be displayed. The problem is that after this character is encountered, the rest of the character is not taken into account. You can work around this problem by using the Execute code: block and enter the code directly

    myVar = 'text\n'

  • @robalstona

    Tnx for the tipp. I'll try it.