How can I use a queryed result?

I can query the position of a partitular particle by going

particle -attribute position -id 5 -q particle1;
// Result: -0.571217 -0.717975 -0.370524 //

How can I use this as the position of a different object??

$val[]=particle -attribute position -id 5 -q particle1;
print ("posX= " + $val[0] );
print ("posY= " + $val[1] );
print ("posZ= " + $val[2] );

this should be of some help in moving forward