If I understand your question correctly, you do not need the loop...
#BUGS script to obtain distribution
m1<-"model{
ind ~ dcat(p[])
pmix <- x[ind]
}"
writeLines(m1,"m1.txt")
#simulate from the distribution
library("R2OpenBUGS")
m1.bug<-bugs(data = list(x=c(10, 15, 20), p=c(0.1,0.2,0.7)),
inits = NULL,
param = "pmix",
model = "m1.txt",
n.iter = 1100, n.burnin = 100, n.chains = 1, n.thin=1, DIC=FALSE)
hist(m1.bug$sims.list$pmix)
should work...