Rename a Module
svoldgaard
✭✭
in RobotStudio
Best Answer
-
I guess you could open your saved .mod file in reading mode. And write all the lines to a new (temporary?) .mod file, while changing the first line. Something in the line of (not tested and my boss would kill me for using bad names and lack of documentation):PROC loadModule()var iodev modulefile;var iodev tempfile;var string line;Open "HOME:/yourmodule.mod", modulefile\READ;Open "HOME:/tempmodule.mod", tempfile\WRITE;line := ReadStr(modulefile); !first line is ignored, as we are writing our own MODULE lineWrite tempfile, "MODULE YourNewModuleName"; !our own MODULE line is written to the temporary fileWHILE line <> EOF DO !loop while we haven't copied everything of our old module to the temporary file;line:=ReadStr(modulefile);Write tempfile, line;ENDWHILE;Close modulefile;Close tempfile;Load \Dynamic, diskhome, \File:="tempmodule.mod"ENDPROCThis is a very simple implementation which assumes that the "MODULE YourModuleName" is the first line. It breaks quite easily, so you might want to build in some checks to prevent writing and loading corrupt module files.5
Answers
-
The first line of the module file holds the module line (both when you open the .mod file in your editor of choice or in RobotStudio)Just change this line after the MODULE command. Example:MODULE MainModulePROC main()!some actionENDPROCENDMODULEchange to:MODULE OtherModuleNamePROC main()!some actionENDPROCENDMODULE0
-
The name in the first line and the file name is not the same! RS just uses the same name.But what I want to do, is to create a copy of a module and load it in to the memory(together with the old module). but it needs to be with rapid code. So manually changing the name will not do!0
-
The filename doesn't matter in execution time, only the name inside the file behind the 'MODULE' keyword.I guess you could use file operations to open the file (as text), change the first line and then save it, but I don't think that would be a very nice solution. Also all routines and/or variables stored in the module will be defined already in your system which could easily give you loads of errors. Can't you unload the old module before loading the new one?0
-
I know that the filename doesn't matter, my problem is that it is the one that I know how to changes. I don't know how to change the module name.How do I open the file, and change the first line? (still in RAPID code)If I define my routines and variables locally, it is no problem.I could unload the module, but the essence is that I would like to avoid that!0
-
That is more or less what I needed. not a pretty solution to copy every single line, but with a little modification it worked.0
Categories
- All Categories
- 5.5K RobotStudio
- 394 UpFeed
- 18 Tutorials
- 13 RobotApps
- 297 PowerPacs
- 405 RobotStudio S4
- 1.8K Developer Tools
- 249 ScreenMaker
- 2.7K Robot Controller
- 309 IRC5
- 59 OmniCore
- 7 RCS (Realistic Controller Simulation)
- 783 RAPID Programming
- AppStudio
- 3 RobotStudio AR Viewer
- 18 Wizard Easy Programming
- 105 Collaborative Robots
- 4 Job listings