Get Program / Module Name?

I have hundreds of programs written for S4C+ and IRC5 controllers that were all written as .PRG files. the current workflow is operators load programs and run for different parts.

I want to keep track of statistics for parts run, but I need to know what programs the operators are running and I don’t want to have to edit every program to output individual program names (I will still have to put similar code in each program however to log the stats, but I want that code to be the same across the board)

What I’m looking for is a command like GetTaskName to capture the currently active robot program / module - thanks!

I’ve found other people on the forum posting similar questions, this seems to be something lacking?

I’m looking for the same exact fonction.

No, I called ABB support and they too could not think of any way to do this. I settled with passing the name as a parameter to my routine, so at least I copy the same routine and just change the one passed string. Obnoxious, but at least it will get done

If you have only one program loaded at a time.
You can make a string variable in each program file or put it inside the template file.

For example:
CONST string nameModule:=“ProgramTemplate”;

When reading your rapid code from system modules you can get value of that referenced string.
Thats how you can get the name of the currently loaded program.

Bellow I have posted an example how I was Erasing currently loaded program. Load \Dynamic was not an option.

PROC rModuleErase()
VAR string l_strModule;

GetDataVal “nameModule”,l_strModule;
EraseModule l_strModule;

ERROR
SkipWarn;
RETURN;
ENDPROC