473,387 Members | 1,553 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Dynamically changing Variable name

AMP
Hello,
I have ArrayLists that are Channel1, Channel 2......Channel16
I want to access them with a (for int s=1;s<17;s++) loop, but I dont
know how to do this:
"Channel+s"
Any help,
Thanks
Mike
Mar 17 '08 #1
4 8634
On Mar 17, 3:01 pm, AMP <ampel...@gmail.comwrote:
I have ArrayLists that are Channel1, Channel 2......Channel16
I want to access them with a (for int s=1;s<17;s++) loop, but I dont
know how to do this:
"Channel+s"
You shold almost certainly be using an array, a list or a dictionary
instead. Why do you feel you *want* to have 16 different variables
rather than one?

Jon
Mar 17 '08 #2
"AMP" <am******@gmail.comwrote in message
news:f5**********************************@v3g2000h sc.googlegroups.com...
Hello,
I have ArrayLists that are Channel1, Channel 2......Channel16
I want to access them with a (for int s=1;s<17;s++) loop, but I dont
know how to do this:
"Channel+s"
Any help,
Thanks
Mike
Variable names are not known at run time. That is a basic principle of
compiled programming languages. (In a language with reflection, such as C#,
it may be possible to retrieve a variable name, but not to change it.)

What you want is an array of ArrayLists: Channel[0][...etc...],
Channel[1][...etc...], and so on.
Mar 17 '08 #3
AMP
On Mar 17, 12:23*pm, "Michael A. Covington" <m...@uga.eduwrote:
"AMP" <ampel...@gmail.comwrote in message

news:f5**********************************@v3g2000h sc.googlegroups.com...
Hello,
I have ArrayLists that are Channel1, Channel 2......Channel16
I want to access them with a (for int s=1;s<17;s++) loop, but I dont
know how to do this:
"Channel+s"
Any help,
Thanks
Mike

Variable names are not known at run time. *That is a basic principle of
compiled programming languages. *(In a language with reflection, such asC#,
it may be possible to retrieve a variable name, but not to change it.)

What you want is an array of ArrayLists: *Channel[0][...etc...],
Channel[1][...etc...], and so on.
Actually the data started out as Arrays and I am finding ArrayLists
allow me to clean the data easier.
I have 12 boards with 16 channels on each board.The amount of data
changes between channels and boards.
I should still be able to use some kind of "for statenent to do my
cleansing on a "Channel+i" basis.
Right?
Thanks
Mike
Mar 17 '08 #4
AMP wrote:
On Mar 17, 12:23 pm, "Michael A. Covington" <m...@uga.eduwrote:
>"AMP" <ampel...@gmail.comwrote in message

What you want is an array of ArrayLists: Channel[0][...etc...],
Channel[1][...etc...], and so on.

Actually the data started out as Arrays and I am finding ArrayLists
allow me to clean the data easier.
I think you missed that AMP wrote "an array of ArrayLists."
If you wanted, though, you could also have "an ArrayList of ArrayLists."

1. Create a new ArrayList called Temp
2. Add Channel1 to it, add Channel2 to it, ....
3. Do a loop on Temp, processing each channel in turn
4. Toss Temp, unless you want to keep it
Mar 18 '08 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: george lewycky | last post by:
Is there someway I can make a parameter or variable of some sort to pass into my PL/SQL cursor shown below to change the value of the date without having to rebuild the package each time?? Can I...
0
by: alex | last post by:
I'm new to xslt, and I am attempting to use it to produce a comma-separated-value file from a large, dynamically-generated data file formatted in xml (examples of the xml file and my xslt style...
4
by: Terry | last post by:
I have a number of input boxes used to display totals based on selected items for each row in a table. There are more than a few rows that are identical, except for the form field name. I have...
4
by: Eric | last post by:
How can I dynamically assign an event to an element? I have tried : (myelement is a text input) document.getElementById('myelement').onKeyUp = "myfnc(param1,param2,param3)"; ...
3
by: lanky_tx | last post by:
Hi All, We have an automated build and test environment using NAnt and Nunit. Some of our assemblies are being strong named by modifying the AssemblyInfo.cs and having csc compile it. Some of...
7
by: Steve_Black | last post by:
Hello, I'm toying with the idea of loading a MenuStrip (VB.Net 2005) dynamically based on who is logged into my system. Every user has different security settings and I want to customize the...
2
by: tshad | last post by:
Is there a way to dynamically add in User Controls where I would get the name from a session variable: If I have the following code:...
1
by: hellohi | last post by:
Hello Everyone, I wanted to change the existing variable names dynamically.( like www.aol.com ) in this site images and some text is changing dynamically. like wise i need javascrip to write ...
1
Merlin1857
by: Merlin1857 | last post by:
How to search multiple fields using ASP A major issue for me when I first started writing in VB Script was constructing the ability to search a table using multiple field input from a form and...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.