Quote from
Gaev on February 25, 2023, 3:59 am
@lolo
I have a multi-line text stored in a variable: - how to change the text of a line?
For multi-line text, each time the user presses the Enter key (to force a line break), the variable contains a Carriage Return (CR) and Line Feed (LF) character.
You can detect these special characters via script by using reserved variables [#13][#10]
If you need to isolate the content of individual lines ...
StrParse "[TextEntry1]" "[#13][#10]" "[myLines]" "[countOfLines]"
... then, [myLines1], [myLines2] etc. will contain the contents of each successive line ... if the desired line number is in a variable (say [thisLine]) ...
SetVar "[desiredLineContent]" "[myLines[thisLine]]"
... will yield the contents of this line in [desiredLineContent]
In order to replace the edited content in the TextEntry Box, you have to concatenate each of the lines, using a Loop/EndLoop block ...
SetVar "[mergedContent]" ""
Loop "1" "[countOfLines]" "[thisLineNumber]"
SetVar "[mergedContent]" "[mergedContent][#13][#10][myLines[thisLineNumber]]"
EndLoop
... remove leading CR LF
SubStr "[mergedContent]" "3" "99999" "[TextEntry1]"
@lolo
I have a multi-line text stored in a variable: - how to change the text of a line?
For multi-line text, each time the user presses the Enter key (to force a line break), the variable contains a Carriage Return (CR) and Line Feed (LF) character.
You can detect these special characters via script by using reserved variables [#13][#10]
If you need to isolate the content of individual lines ...
StrParse "[TextEntry1]" "[#13][#10]" "[myLines]" "[countOfLines]"
... then, [myLines1], [myLines2] etc. will contain the contents of each successive line ... if the desired line number is in a variable (say [thisLine]) ...
SetVar "[desiredLineContent]" "[myLines[thisLine]]"
... will yield the contents of this line in [desiredLineContent]
In order to replace the edited content in the TextEntry Box, you have to concatenate each of the lines, using a Loop/EndLoop block ...
SetVar "[mergedContent]" ""
Loop "1" "[countOfLines]" "[thisLineNumber]"
SetVar "[mergedContent]" "[mergedContent][#13][#10][myLines[thisLineNumber]]"
EndLoop
... remove leading CR LF
SubStr "[mergedContent]" "3" "99999" "[TextEntry1]"
luishp, Vadim and luiz have reacted to this post.