remove line breaks from variable

Discuss RoboTask here
Post Reply
Brad
Posts: 7
Joined: Sat May 01, 2010 5:00 am

remove line breaks from variable

Post by Brad »

I am extracting info from an email and writing it to a text file.Sometimes the user writes information over 2 lines and I need to write it as a single line.For example:"Level 239 main street"Needs to be written as "level 2 39 main St"Ideally replace the new line with another character - perhaps a '-'.Can't be comma as the output is comma delimited.Any ideas?
Brad
Posts: 7
Joined: Sat May 01, 2010 5:00 am

remove line breaks from variable

Post by Brad »

should probably mention that "Level 239 main street"is held as a single variable, and this is the exception to the typical data I  am extracting.
Oleg
Site Admin
Posts: 3202
Joined: Thu Jan 01, 1970 1:00 am
Contact:

remove line breaks from variable

Post by Oleg »

See the example below. I made two replacements
symbol #13 (CR) to empty string
symbol #10 (LF) to "-" char.

Save the text of task to file and use menu Task | Import

;*****************************
;* RoboTask Task file
;* Do not edit in text editor!
;*****************************

[Root]
ActionAfterRun=INTEGER|0
Actions=FOLDER
Automat=INTEGER|-1
CatID=INTEGER|839555382
Comment=STRINGLIST
ContinueOnError=INTEGER|0
ExternalName=STRING|"Task1014"
Hide=INTEGER|0
ID=INTEGER|2034820528
LocalVariables=STRING|"MyStr"
LogOnAsUser=INTEGER|1
Name=STRING|"Remove EOL symbols"
OnErrorTaskID=INTEGER|0
Priority=INTEGER|3
RunOnClose=INTEGER|0
RunOnStartup=INTEGER|0
ToLog=INTEGER|3
WriteGeneralLog=INTEGER|0

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

[Actions\Action1]
ActionID=STRING|"A_VARIABLES_SET"
Enabled=INTEGER|-1
Name=STRING|"Set variable ""MYSTR"" with value ""Level 2{EOL}39 main street"""
Params=FOLDER

[Actions\Action1\Params]
expand=STRING|"0"
varname=STRING|"MYSTR"
varvalue=STRING|"Level 2{EOL}39 main street"

[Actions\Action2]
ActionID=STRING|"A_DIALOG_MESSAGE"
Enabled=INTEGER|-1
Name=STRING|"Show ""{Mystr}"""
Params=FOLDER

[Actions\Action2\Params]
icon=STRING|"1"
msg0=STRING|"{Mystr}"
msgcount=STRING|"1"
playsound=STRING|"0"
showmessage=STRING|"1"

[Actions\Action3]
ActionID=STRING|"A_STR_REPLACE"
Enabled=INTEGER|-1
Name=STRING|"STR Replace"
Params=FOLDER

[Actions\Action3\Params]
case=STRING|"0"
mode=STRING|"0"
source=STRING|"{MyStr}"
substring=STRING|"{Chr(13)}"
variable=STRING|"MyStr"

[Actions\Action4]
ActionID=STRING|"A_STR_REPLACE"
Enabled=INTEGER|-1
Name=STRING|"STR Replace"
Params=FOLDER

[Actions\Action4\Params]
case=STRING|"0"
mode=STRING|"0"
replacement=STRING|"-"
source=STRING|"{MyStr}"
substring=STRING|"{Chr(10)}"
variable=STRING|"MyStr"

[Actions\Action5]
ActionID=STRING|"A_DIALOG_MESSAGE"
Enabled=INTEGER|-1
Name=STRING|"Show ""{Mystr}"""
Params=FOLDER

[Actions\Action5\Params]
icon=STRING|"1"
msg0=STRING|"{Mystr}"
msgcount=STRING|"1"
playsound=STRING|"0"
showmessage=STRING|"1"
Brad
Posts: 7
Joined: Sat May 01, 2010 5:00 am

remove line breaks from variable

Post by Brad »

Perfect - thank you :)
Post Reply