Place text

Discuss RoboTask here
Post Reply
degoup
Posts: 4
Joined: Mon Aug 20, 2007 7:09 am

Place text

Post by degoup »

I seek to replace a parameter in a file existing at a quite precise place. This one is in tenth line. I am able to put it in top or bottom but not at the good place

;**********************
;* RoboTask Task file *
;* Do not edit!       *
;**********************

[Root]
ActionAfterRun=INTEGER|0
Actions=FOLDER
Automat=INTEGER|-1
CatID=INTEGER|385352816
ContinueOnError=INTEGER|0
ExternalName=STRING|"Task3"
Hide=INTEGER|0
ID=INTEGER|1504975704
Name=STRING|"Create text file C:\Documents and Settings\ROUX\Bureau\TEST OK.txt..."
Priority=INTEGER|3
RunOnClose=INTEGER|0
RunOnStartup=INTEGER|0
ToLog=INTEGER|3

[Actions]
Action1=FOLDER

[Actions\Action1]
ActionID=STRING|"A_FILE_TEXTWRITE"
Enabled=INTEGER|-1
Name=STRING|"Create text file C:\Documents and Settings\ROUX\Bureau\Move_Print.ini"
Params=FOLDER

[Actions\Action1\Params]
fileexists=STRING|"0"
filname=STRING|"C:\Documents and Settings\ROUX\Bureau\Move_Print.ini"
line0=STRING|"{INSERT}"
line1=STRING|"{TEXTFILE(Move_Print.ini)}"
line2=STRING|"{INSERT}"
linecount=STRING|"3"

 
Oleg
Site Admin
Posts: 3202
Joined: Thu Jan 01, 1970 1:00 am
Contact:

Place text

Post by Oleg »

If you want to replace some specific line, you have to use text loop.
See example below.
Suppose user variable "INSERT" contains new line. The task replaces 10-th line of text to new line.


;**********************
;* RoboTask Task file *
;* Do not edit!       *
;**********************

[Root]
ActionAfterRun=INTEGER|0
Actions=FOLDER
Automat=INTEGER|0
CatID=INTEGER|1947094105
ContinueOnError=INTEGER|0
ExternalName=STRING|"Task518"
Hide=INTEGER|0
ID=INTEGER|47088364
Name=STRING|"replace 10-th line of the text"
Priority=INTEGER|3
RunOnClose=INTEGER|0
RunOnStartup=INTEGER|0
ToLog=INTEGER|3

[Actions]
Action1=FOLDER
Action10=FOLDER
Action11=FOLDER
Action2=FOLDER
Action3=FOLDER
Action4=FOLDER
Action5=FOLDER
Action6=FOLDER
Action7=FOLDER
Action8=FOLDER
Action9=FOLDER

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

[Actions\Action1\Params]
expand=STRING|"0"
varname=STRING|"LINE_NUM"
varvalue=STRING|"1"

[Actions\Action10]
ActionID=STRING|"A_LOOP_END"
Enabled=INTEGER|-1
Name=STRING|"End Loop"

[Actions\Action11]
ActionID=STRING|"A_FILE_TEXTWRITE"
Enabled=INTEGER|-1
Name=STRING|"Create text file C:\Documents and Settings\ROUX\Bureau\Move_Print.ini"
Params=FOLDER

[Actions\Action11\Params]
fileexists=STRING|"0"
filname=STRING|"C:\Documents and Settings\ROUX\Bureau\Move_Print.ini"
line0=STRING|"{new_text}"
linecount=STRING|"1"

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

[Actions\Action2\Params]
expand=STRING|"0"
varname=STRING|"NEW_TEXT"

[Actions\Action3]
ActionID=STRING|"A_LOOP_TEXT"
Enabled=INTEGER|-1
Name=STRING|"Text Loop"
Params=FOLDER

[Actions\Action3\Params]
destvar=STRING|"C_LINE"
file=STRING|"C:\Documents and Settings\ROUX\Bureau\Move_Print.ini"
linecount=STRING|"0"
sourcetext=STRING|"0"

[Actions\Action4]
ActionID=STRING|"A_FLOW_IF"
Enabled=INTEGER|-1
Name=STRING|"If Then"
Params=FOLDER

[Actions\Action4\Params]
case=STRING|"0"
operator=STRING|"0"
type=STRING|"1"
value1=STRING|"{line_num}"
value2=STRING|"10"

[Actions\Action5]
ActionID=STRING|"A_VARIABLES_SET"
Enabled=INTEGER|-1
Name=STRING|"Set variable ""NEW_TEXT"" with value ""{new_text}{insert}{Eol}"""
Params=FOLDER

[Actions\Action5\Params]
expand=STRING|"1"
varname=STRING|"NEW_TEXT"
varvalue=STRING|"{new_text}{insert}{Eol}"

[Actions\Action6]
ActionID=STRING|"A_FLOW_ELSE"
Enabled=INTEGER|-1
Name=STRING|"Else"

[Actions\Action7]
ActionID=STRING|"A_VARIABLES_SET"
Enabled=INTEGER|-1
Name=STRING|"Set variable ""NEW_TEXT"" with value ""{new_text}{c_line}{Eol}"""
Params=FOLDER

[Actions\Action7\Params]
expand=STRING|"1"
varname=STRING|"NEW_TEXT"
varvalue=STRING|"{new_text}{c_line}{Eol}"

[Actions\Action8]
ActionID=STRING|"A_FLOW_ENDIF"
Enabled=INTEGER|-1
Name=STRING|"End If"

[Actions\Action9]
ActionID=STRING|"A_VARIABLES_INCREMENT"
Enabled=INTEGER|-1
Name=STRING|"Increment variable ""line_num"""
Params=FOLDER

[Actions\Action9\Params]
incement=STRING|"1"
vaiable=STRING|"line_num"
degoup
Posts: 4
Joined: Mon Aug 20, 2007 7:09 am

Place text

Post by degoup »

Oleg,
Thanks very much, it's perfect......
I bought your soft yesterday, it's véry cool...
Dégoup
validator
Posts: 3
Joined: Wed Mar 25, 2009 4:46 am
Location: France

Place text

Post by validator »

Oleg,
I tried the solution you suggested, but unfortunately it does not work like i want. Nothing from my txt file is copied in the specific of the program. For this line you must read :
"I tried the solution you suggested, but unfortunately it does not work like i want. Nothing from my txt file is copied in the specific "field" of the program.

 
 
Post Reply