Following Rich's idea, I couldn't get the popup to appear, but I've managed to devise a similar script to shove everything into variables and then I can use the popup to do what I want

Thanks for your ideas and help grin