ok not knowing the program, I programmed a small sample.
here a small description:
I add the images into a family, add a family variable (right click), click each image in the family and name it.
Now you know which image/lot will be clicked.
I include 3 version (put you also can do this in one function, but this will be more difficult to understand):
a.) showing the image name (the ID)
the command function.param(0) use the variable within the function. It is passed when you call it (you can add several param and use it with function.param(1)
b.) compare variables
when this variable is clicked do this,.... when this clicked do this...
you can also calculate or do other stuff. Not just showing text
you can also combine it