Jump to content

Eval Expression


kubabuk

Recommended Posts

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...