Hi guys!
I have a problem with my C-shell program.
For example.
We have 3 position in office: manager, accountant and administrator. Everyone positions has descriptions: person name, person age, person sex and her phone. We need create cycle and show all personal data.
P.S. The problem was invented - just an example. The purpose of the issue conversion of strings to the command (maybe using eval).
It's works. We converted text "manager" to script-variable and write this data to current variable.
But, we should review all positions. For this I create array:
set office=(manager accountant administrator)
I'm trying to take the first element of the array and get his data:
This is not working.
Help me guys - how to take the word of the array, convert it to a variable and get the data out of it?
P.S. Sorry for my English.
I have a problem with my C-shell program.
For example.
We have 3 position in office: manager, accountant and administrator. Everyone positions has descriptions: person name, person age, person sex and her phone. We need create cycle and show all personal data.
P.S. The problem was invented - just an example. The purpose of the issue conversion of strings to the command (maybe using eval).
Code:
#!/bin/csh
# NAME AGE SEX PHONE
set manager=('M.Jon' '21' 'M' '7263627')
set accountant=('J.Melisa' '30' 'W' '6473647')
set administartor=('K.Alen' '25' 'M' '7263127')
set evalvar='set current=($manager)'
eval $evalvar
printf "\
NAME:\t$current[1]\
AGE:\t$current[2]\
SEX:\t$current[3]\
PHONE:\t$current[4]\n"
exit(0)
It's works. We converted text "manager" to script-variable and write this data to current variable.
But, we should review all positions. For this I create array:
set office=(manager accountant administrator)
I'm trying to take the first element of the array and get his data:
Code:
#!/bin/csh
# NAME AGE SEX PHONE
set manager=('M.Jon' '21' 'M' '7263627')
set accountant=('J.Melisa' '30' 'W' '6473647')
set administartor=('K.Alen' '25' 'M' '7263127')
set office=(manager accountant administrator)
set evalvar='set current=(\$'"${office[1]})"
printf "\nIn EVALVAR:\n$evalvar\n" # Here I see that the variable $evalvar
# is written string 'set current=($manager)',
# the same line as the previous example.
eval $evalvar
printf "\
NAME:\t$current[1]\
AGE:\t$current[2]\
SEX:\t$current[3]\
PHONE:\t$current[4]\n"
exit(0)
This is not working.
Help me guys - how to take the word of the array, convert it to a variable and get the data out of it?
P.S. Sorry for my English.