Action "TXT Delete line" doesn't work as expected with multiline variables

Discuss RoboTask here
Post Reply
juanlu
Posts: 46
Joined: Wed Jul 31, 2019 12:33 am

Action "TXT Delete line" doesn't work as expected with multiline variables

Post by juanlu »

Hi Oleg,

The action "TXT Delete line" has a strange behaviour with multiline variables. The line is deleted, yes, but a new empty line is added at the end of the multiline variable. So the number of lines stays the same instead of being reduced by 1.

Example:
Line 1
Line 2
Line 3

TXT Delete line -> delete line 2

Result:
Line 1
Line 3
<Empty line>

This is not only confusing; if you use this multiline variable in a Text Loop action, you would have a incorrect behaviour (looping through empty values).

Could you please look into this?

Kind regards, Juanlu.
Oleg
Site Admin
Posts: 3000
Joined: Thu Jan 01, 1970 1:00 am
Contact:

Re: Action "TXT Delete line" doesn't work as expected with multiline variables

Post by Oleg »

It works correctly
Look at my example below. Save the text of the task to a file and use menu Task->Import to import the task into RoboTask.
Also you can simply copy task text and paste it into the task list.

Code: Select all

;*****************************
;* RoboTask Task file
;* Do not edit in text editor!
;*****************************
 
[Root]
ActionAfterRun=INTEGER|0
Actions=FOLDER
Automat=INTEGER|-1
CatID=INTEGER|693415217
Comment=STRINGLIST
ContinueOnError=INTEGER|0
DisableOnError=INTEGER|0
DoNotStopWhenShutdown=INTEGER|0
ExternalName=STRING|"Task50"
Hide=INTEGER|0
ID=INTEGER|443491465
LogOnAsUser=INTEGER|1
Name=STRING|"remove 2-nd line"
OnErrorTaskID=INTEGER|1879502808
Priority=INTEGER|3
RunOnClose=INTEGER|0
RunOnStartup=INTEGER|0
ToLog=INTEGER|3
UnicodeFormat=INTEGER|1
WriteGeneralLog=INTEGER|0

[Actions]
Action1=FOLDER
Action2=FOLDER
Action3=FOLDER
Action4=FOLDER

[Actions\Action1]
ActionID=STRING|"A_VARIABLES_SET"
Enabled=INTEGER|-1
Name=STRING|"Set variable ""txt"" with value ""Line 1"""
Params=FOLDER

[Actions\Action1\Params]
expand=STRING|"0"
linecount=STRING|"3"
varname=STRING|"txt"
varvalue=STRING|"Line 1"
varvalue00000001=STRING|"Line 2"
varvalue00000002=STRING|"Line 3"

[Actions\Action2]
ActionID=STRING|"A_ROBOTASK_LOG"
Enabled=INTEGER|-1
Name=STRING|"Log Message"
Params=FOLDER

[Actions\Action2\Params]
message=STRING|"{txt}"
type=STRING|"3"

[Actions\Action3]
ActionID=STRING|"A_TXT_DELETELINE"
Enabled=INTEGER|-1
Name=STRING|"TXT Delete line"
Params=FOLDER

[Actions\Action3\Params]
external=STRING|"0"
line00000000=STRING|"{txt}"
linecount=STRING|"1"
linenum=STRING|"2"
variable=STRING|"txt"

[Actions\Action4]
ActionID=STRING|"A_ROBOTASK_LOG"
Enabled=INTEGER|-1
Name=STRING|"Log Message"
Params=FOLDER

[Actions\Action4\Params]
message=STRING|"{txt}"
type=STRING|"3"

BUT
please note that each line ends with end-or-line symbols
If you want to cut off last EOL symbols use STR trim action
If you use Write Text File action to save text to a file then use "Suppress Trailing End-Of-Line symbols" option
Oleg Yershov
Post Reply