Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations cowski on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Create Struct using variable values?

Status
Not open for further replies.

TimJrSSTi

Computer
Joined
Mar 23, 2009
Messages
2
Location
US
Is there a way to create a struct using the value of a variable?

For example say I had the following variables:

league='MLB'
team='Phillies'

How can I create a struct that looks like the following using the variables league & team:

MLB.Phillies.player1='Utley'

Is it even possible?
 
Anything is possible if you cross over into the dark side and use "eval". Don't expect your code to be readable though. Do expect your workspace to become flooded with variables.

- Steve
 
I did find a round about way to do it using "eval". It ain't pretty, but it works.

Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top