thislist is a trigger command: "thislist" is the array of units in the trigger area that would fire the trigger. For example, all the east units in an "east present" trigger. (Or an east not present one, actually.)
There are two ways to identify the position of a group: either use the position of the group leader as a proxy for the group's position (getPos leader grp1); or discover the positions of all the group members and use trigonometry to combine them into an "average" position. In this case you could perhaps use the position of the nearest soldier as a proxy.
Once you have the position, you can use the distance command to measure the distance between it and the click. You'll probably have to put a GL at each position to give you something to measure. Notice that the click will (I think) be at sea level not ground level, so you may have to be careful.
If you have manually assigned groups then your array of groups is the one that you want it to be: infantry2 don't come into this at all. In other words, you don't need to check if the infantry group is in 1 or 2, just excercise the script on 1 only.
Sadly I'm not enough of a scripter to take this much further, but I hope that helps. I don't know much about MP either, except that scripts are a little tricky. I suspect in this case you would run the script on the server only and only broadcast the result.