kubabuk Posted May 11, 2007 Share Posted May 11, 2007 I have a following situation. I've created several variables and using while loop I want to concatenate two strings to form a variable name, in each loop different one. I am not sure if I used eval expression properly but with or without that doesn't work/ Could someone point me out what is wrong here, please ? set box1 = "Rb05" set box2 = "Rb06" set box3 = "Rb07" set i = 0 while ($i < 3 ) set i = `($i+1)` echo `eval(strcat("$box",$i ))` end thanks kuba Quote Link to comment Share on other sites More sharing options...
crunch Posted May 11, 2007 Share Posted May 11, 2007 I have a following situation. I've created several variables and using while loop I want to concatenate two strings to form a variable name, in each loop different one. I am not sure if I used eval expression properly but with or without that doesn't work/ Could someone point me out what is wrong here, please ?set box1 = "Rb05" set box2 = "Rb06" set box3 = "Rb07" set i = 0 while ($i < 3 ) set i = `($i+1)` echo `eval(strcat("$box",$i ))` end thanks kuba You can also do this by: val = ${Rb$i} The stuff inside the {} is expanded to determine the variable name. Quote Link to comment Share on other sites More sharing options...
symek Posted May 11, 2007 Share Posted May 11, 2007 for i = 1 to 3 echo ${nazwa$i} end czolem, sy. PS pisujemy, co..? Quote Link to comment Share on other sites More sharing options...
kubabuk Posted May 11, 2007 Author Share Posted May 11, 2007 That's very useful! Thanks a lot. PS pisujemy, co..? troszke, w wolnych chwilach... Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.