# Amend module file

**URL:** <https://tech-community.robotics.abb.com/t/amend-module-file/7763>\
**Category:** RobotStudio\
**Tags:** robotstudio\
**Created:** [June 8, 2017, 10:46am UTC](https://tech-community.robotics.abb.com/t/amend-module-file/7763 "2017-06-08T10:46:22Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ko414du4](https://avatars.discourse-cdn.com/v4/letter/k/e19b73/32.png) [@ko414du4](https://tech-community.robotics.abb.com/u/ko414du4)\
**Post date:** [June 8, 2017, 10:46am UTC](https://tech-community.robotics.abb.com/t/amend-module-file/7763/1 "2017-06-08T10:46:22Z")

</div>

Greetings all,

I am trying to add a routine in a module file located in “Home:/”.By this, I mean keeping the existing contents and then add a routine at the end of the module just before ‘ENDMODULE’ line.

# ===================================================================== Code:

VAR iodev readingChannel;  
VAR iodev writingChannel;  
VAR string line;

! Append new recipe routine  
Open “HOME:/Recipes.mod”,writingChannel\Append;  
Write writingChannel,“! New routine here”;  
Write writingChannel,“PROC newProc()”;  
Write writingChannel,“! Test”;  
Write writingChannel,“ENDPROC”;  
Write writingChannel,“ENDMODULE”;  
Close writingChannel;

! Read result and get rid of old ENDMODULE lines. Add ENDMODULE to the end instead.  
Open “HOME:/Recipes.mod”,readingChannel\Read\Bin;  
Open “HOME:/temp.mod”,writingChannel\Write\Bin;  
line:=ReadStr(readingChannel);  
WHILE (line\<\>EOF) DO  
IF (line \<\> “ENDMODULE”) Write writingChannel,line;  
line:=ReadStr(readingChannel);  
ENDWHILE  
Write writingChannel,“ENDMODULE”;

! Close channels  
Close readingChannel;  
Close writingChannel;

! Copy temp module to Recipes.mod  
Open “HOME:/temp.mod”,readingChannel\Read;  
Open “HOME:/Recipes.mod”,writingChannel\Write;  
line:=ReadStr(readingChannel);  
WHILE line\<\>EOF DO  
IF (line \<\> “ENDMODULE”) Write writingChannel,line;  
line:=ReadStr(readingChannel);  
ENDWHILE  
Write writingChannel,“ENDMODULE”;

! Close channels  
Close readingChannel;  
Close writingChannel;

# Stop;

The issue I have now is that function ReadStr() cannot read more than 80 chars. While the existing contents has robtarget data that exceed this limit, and therefore the line is chopped and continued on the next line like below:

# ===================================================================== Result:

MODULE Recipes

PROC Recipe\_33()

opsSets:=[  
[1,[[-1819.4,712.469,1163.07],[1.265E-06,0.818184,-0.574957,1.29455E-06]

,[0,0,-1,0],[9E+09,9E+09,9E+09,9E+09,9E+09,9E+09]],222,2,222],  
[2,[[-2712.47,-1319.4,384.069],[2.08991E-08,-0.985099,-0.171988,-1.80987

E-06],[0,0,-1,0],[9E+09,9E+09,9E+09,9E+09,9E+09,9E+09]],33,3,333],  
[3,[[-2712.47,-1319.4,384.069],[2.08991E-08,-0.985099,-0.171988,-1.80987

E-06],[0,0,-1,0],[9E+09,9E+09,9E+09,9E+09,9E+09,9E+09]],33,3,333],  
[0,[[0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0,0,0]],0,0,0],  
[0,[[0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0,0,0]],0,0,0],  
[0,[[0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0,0,0]],0,0,0],  
[0,[[0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0,0,0]],0,0,0],  
[0,[[0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0,0,0]],0,0,0],  
[0,[[0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0,0,0]],0,0,0],  
[0,[[0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0,0,0]],0,0,0],  
[0,[[0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0,0,0]],0,0,0],  
[0,[[0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0,0,0]],0,0,0],  
[0,[[0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0,0,0]],0,0,0],  
[0,[[0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0,0,0]],0,0,0],  
[0,[[0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0,0,0]],0,0,0],  
[0,[[0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0,0,0]],0,0,0],  
[0,[[0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0,0,0]],0,0,0],  
[0,[[0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0,0,0]],0,0,0],  
[0,[[0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0,0,0]],0,0,0],  
[0,[[0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0,0,0]],0,0,0],  
[0,[[0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0,0,0]],0,0,0],  
[0,[[0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0,0,0]],0,0,0],  
[0,[[0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0,0,0]],0,0,0],  
[0,[[0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0,0,0]],0,0,0],  
[0,[[0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0,0,0]],0,0,0],  
[0,[[0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0,0,0]],0,0,0],  
[0,[[0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0,0,0]],0,0,0],  
[0,[[0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0,0,0]],0,0,0],  
[0,[[0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0,0,0]],0,0,0],  
[0,[[0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0,0,0]],0,0,0]]

ENDPROC

! New routine here  
PROC newProc()  
! Test  
ENDPROC

ENDMODULE

=====================================================================

Is there any way of getting around this ReadStr() limitation of 80 chars? So the line is not chopped?

---

<div class="post-metadata">

**Author:** ![graemepaulin](https://avatars.discourse-cdn.com/v4/letter/g/258eb7/32.png) [@graemepaulin](https://tech-community.robotics.abb.com/u/graemepaulin)\
**Post date:** [June 8, 2017, 8:47pm UTC](https://tech-community.robotics.abb.com/t/amend-module-file/7763/2 "2017-06-08T20:47:43Z")

</div>

Why not do the changes in RobotStudio and then save the modified file back to the controller?

---

<div class="post-metadata">

**Author:** ![ko414du4](https://avatars.discourse-cdn.com/v4/letter/k/e19b73/32.png) [@ko414du4](https://tech-community.robotics.abb.com/u/ko414du4)\
**Post date:** [July 19, 2017, 5:03am UTC](https://tech-community.robotics.abb.com/t/amend-module-file/7763/3 "2017-07-19T05:03:58Z")

</div>

> [@graemepaulin](#):
>
> Why not do the changes in RobotStudio and then save the modified file back to the controller?

Because I want to be able to modify “HOME:/Recipes.mod” routine on-the-fly which is done on Flexpendant via UI interaction with user.
