STR Replace `n

Discuss RoboTask here
Post Reply
kunkel321
Posts: 30
Joined: Sun Mar 15, 2020 5:23 pm

STR Replace `n

Post by kunkel321 »

Hi There, I'd like to find-and-replace a "new line character" in a string of text. I think that's what you call it?

For example given this
Fib
Wap
Ding
Bar
I'd like to find `n and replace it with | and the result would be:
Fib|Wap|Ding|Bar
I tried
`n
\n
<New Line>
<Enter>
None of them work.
Oleg
Site Admin
Posts: 3014
Joined: Thu Jan 01, 1970 1:00 am
Contact:

Re: STR Replace `n

Post by Oleg »

Look at my example

Code: Select all

;*****************************
;* RoboTask Task file
;* Do not edit in text editor!
;*****************************
 
[Root]
ActionAfterRun=INTEGER|0
Actions=FOLDER
Automat=INTEGER|-1
CatID=INTEGER|444033236
Comment=STRINGLIST
ContinueOnError=INTEGER|0
DoNotStopWhenShutdown=INTEGER|0
ExternalName=STRING|"Task170"
Hide=INTEGER|0
ID=INTEGER|-1044006952
LogOnAsUser=INTEGER|1
Name=STRING|"replace ""end-of-line"""
OnErrorTaskID=INTEGER|-1
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
Action5=FOLDER

[Actions\Action1]
ActionID=STRING|"A_VARIABLES_SET"
Enabled=INTEGER|-1
Name=STRING|"Set variable ""TXT"" with value ""Fib{EOL}Wap{EOL}Ding{EOL}Bar"""
Params=FOLDER

[Actions\Action1\Params]
expand=STRING|"0"
varname=STRING|"TXT"
varvalue=STRING|"Fib{EOL}Wap{EOL}Ding{EOL}Bar"

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

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

[Actions\Action3]
ActionID=STRING|"A_STR_REPLACE"
Enabled=INTEGER|-1
Name=STRING|"STR Replace (remove #13 symbol)"
Params=FOLDER

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

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

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

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

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

Save the text of the task to a file and use menu Task->Import to import the task into RoboTask.
Oleg Yershov
kunkel321
Posts: 30
Joined: Sun Mar 15, 2020 5:23 pm

Re: STR Replace `n

Post by kunkel321 »

Ah yes! Now that I think of it, the corresponding character in Excel is CHAR(13), so this makes sense. Thanks Oleg!

EDIT: Strange how is takes two steps. Chr(13) to Chr(10) to "|." A bit kludgy, but that's okay--It seems to work fine. :geek:
Post Reply