it is possible that the study and distributor fields may have more than one. As the country this field that can be several countries. Example: Study:Universal and Rxd Distributor:Paramount and demonit
Please try to explain your questions and suggestions a little bit better so that nobody has to guess what you are really thinking of.
Now to the answer - if I have understand your question correctly. Put as example the #TAKESTUDIO# into a loop and each time the script comes to this command XMM adds the studio to the already existing one(s). Same for #TAKEDISTRIBUTOR#.
In order to achieve what is possible, you have to try the impossible over and over again. Hermann Hesse