I’m facing a problem ! I need to update a module which contain varaibles and routines shared with other modules.
So I want to use UnLoad and Load instructions, but of course, if the module isn’t present in the system, I have semantic errors. So I can’t execute the Load instruction.
You should be able to use Load and UnLoad or StartLoad and WaitLoad, but the module you are unloading needs to have been loaded with a load instruction from within RAPID.
The following code only works because the module to be unloaded was loaded in RAPID to begin with:
There are 3 modules, and it looks like persistents are maintained throughout, although I think variables will be initialised again.
MODULE RemoveModule
PERS num nVar1;
VAR string sVar2 := "asd";
PROC Routine1()
! Do Stuff
nVar1 := 1;
TpWrite "set nVar1 to " \num:=nVar1;
ENDPROC
ENDMODULE
MODULE TempModule
PERS num nVar1;
VAR string sVar2;
PROC Routine1()
! Do Stuff
TpWrite " ";
TPWrite "Value of nVar1 is " \Num:=nVar1;
nVar1 := 2;
TPWrite "Set Value of nVar1 to " \Num:= nVar1;
ENDPROC
ENDMODULE
Execute the unload from your main task ideally while there is no other execution to be safe,
You can disable “Check unresolved references” then you won’t get any syntax error for missing variables och procs. But the program will stop if trying to read / write any missing data.
Hello,
I am struggling at using a sequence of Unload + StartLoad in my program and I feel it looks quite like the problem described in this thread by @Forge_Engineering :
Situation: I want to execute a program after the module is loaded into the task. This loading comes up after the .mod file has been put in the HOME folder of the robot. The robot is sometimes turned off between two executions on purpose (over night for example). This the reason why at program start, I check if the module of the day is newer than the one of the day before, and load it in the task in latter case.
Problem: The robot is turned on and there is already the module in the task. When I try to unload the module and replace it by the new one, I have an error “Module must first be loaded using StartLoad”.
Thus I try to remove the Unload instruction and only use Startload. Now it says “the module already exists and cannot be loaded in task”
So long story short I can’t unload the old one because from the robot perspective, “it has not been loaded yet”, but I can’t load the new one because there’s already one in the Task…
Is there anyone who knows how I am supposed to do ?