RobotStudio event

Rename a Module

Is there any way to rename the name of a module on execution?

Not the name that is used to store the .MOD file, but the actual module name that the rapid program uses!
Tagged:

Best Answer

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 MainModule
    PROC main()
    !some action
    ENDPROC
    ENDMODULE

    change to:

    MODULE OtherModuleName
    PROC main()
    !some action
    ENDPROC
    ENDMODULE
  • 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!
  • 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?
  • 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!
  • That is more or less what I needed. not a pretty solution to copy every single line, but with a little modification it worked.