Solved

USING EVAL IN LOOP

Posted on 2004-08-24
2
208 Views
Last Modified: 2010-04-03
How do I code the following case statements in loop (for next). I tried
eval("myCO"+i) = new Color(eval("lot_"+i)). IT DID NOT WORK

switch (i) {
                  case 0 :
                    myCO0 = new Color(lot_0);
                    break;
                  case 1 :
                    myCO1 = new Color(lot_1);
                    break;
                  case 2 :
                    myCO2 = new Color(lot_2);
                    break;
                  case 3 :
                    myCO3 = new Color(lot_3);
                    break;
                  case 4 :
                    myCO4 = new Color(lot_4);
                    break;
                  case 5 :
                    myCO5 = new Color(lot_5);
                    break;
                  case 6 :
                    myCO6 = new Color(lot_6);
                   break;
                  }
0
Comment
Question by:amiteshsinha
2 Comments
 
LVL 10

Expert Comment

by:muso120999
ID: 11884968
Can you not use something like:
this["myCO"+i] = new Color(this["lot_"+i]);

"this" might have to be substituted for the container object.

I think the eval you are using just returns the value of the variable, rather than the variable itself.

I don't know the code you are using, but I think I would be tempted to use Arrays anyway.
0
 
LVL 39

Accepted Solution

by:
blue-genie earned 125 total points
ID: 11889916
why do you want to loop it?
0

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Recently, I was asked to recommend a tracking system to be implemented on a clients website. As the entire site was built on flash, my first thought was to suggest custom built tracking system. However, our company at that point of time didn't h…
Here are some practices and techniques that can be adopted into your Flash/Flex application development process. Note: Not all "performance tips" provide an immediately-recognizable benefit.   This article does not include timing validation data,…
The goal of the tutorial is to teach the user how to live broadcast using Flash Media Live Encoder and connecting it to YouTube to broadcast. Log into your Youtube account, choose live stream settings, start live stream from Flash Media Live Enc…
The goal of the tutorial is to teach the user how to use the auto adjust feature and what the different options do. When your video is not working right you can choose the auto adjust feature to help choose your settings.

829 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question