How to procedurally change multiple sprites

Hi, I am trying to make my code as neat and efficient as possible but seem to not be able to find something I thought should be simple.

I have five sprites called P1,P2,P3.P4,P5 and I want to alter attrubutes on all of them. I hoped that I could create a counted loop 1-5 and at each step be able to programmatically be able to select each sprite and change something but I can see how you ca do this and I dont want an if then as the number of sprites may change . Something like this

For x = 1 to 5
spritename = “p” + x
Set spritename.image to ‘xyz.jpg’
next

Is this possible I cant see how?

Tony

Here’s a sample app …

Will this work for you?

blocks (3)