473,321 Members | 1,877 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,321 software developers and data experts.

Variable interpolation

Hi there..

I am wondering if it is possible to interpolate the value of a
variable to reference a variable to gain its value.

For example:-

if I have a series of variables:-

var01
var02
var03
var04

(I would arrange them into an array, but they are being generated via
form input)

Let's say I wanted to access these in order using a loop, I would
quite like to use a counter variable that I can increment each time;
counterVar.

Ideally I would like to be able to access the variables using
something to the effect of:-

Console.Writeline(var + counterVar);

counterVar++

Console.Writeline(var + counterVar);

using PHP I would achieve this using $var{$counterVar}
(to give another example).

I hope someone can shed some light onto whether or not this is
possible.

Thanks in advance

Jason Dunbar
Nov 16 '05 #1
4 5262
Hi Jason,

That is easy using an interpreted language, it's as easy using a compiled
one.
With that in mind you have to find another solution, one could be using a
hashtable, you can use the "name" of the variable as the key.
Cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Jason Dunbar" <jason__D0T__dunbar__AT__intechnology__D0T__co__D0 Tuk> wrote
in message news:kv********************************@4ax.com...
Hi there..

I am wondering if it is possible to interpolate the value of a
variable to reference a variable to gain its value.

For example:-

if I have a series of variables:-

var01
var02
var03
var04

(I would arrange them into an array, but they are being generated via
form input)

Let's say I wanted to access these in order using a loop, I would
quite like to use a counter variable that I can increment each time;
counterVar.

Ideally I would like to be able to access the variables using
something to the effect of:-

Console.Writeline(var + counterVar);

counterVar++

Console.Writeline(var + counterVar);

using PHP I would achieve this using $var{$counterVar}
(to give another example).

I hope someone can shed some light onto whether or not this is
possible.

Thanks in advance

Jason Dunbar

Nov 16 '05 #2
Jason,

The best way to do this would be to store the values in a Hashtable (a
Dictionary<> in .NET 2.0, for strongly typed lookup tables) and then key it
on a string that you can generate.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Jason Dunbar" <jason__D0T__dunbar__AT__intechnology__D0T__co__D0 Tuk> wrote
in message news:kv********************************@4ax.com...
Hi there..

I am wondering if it is possible to interpolate the value of a
variable to reference a variable to gain its value.

For example:-

if I have a series of variables:-

var01
var02
var03
var04

(I would arrange them into an array, but they are being generated via
form input)

Let's say I wanted to access these in order using a loop, I would
quite like to use a counter variable that I can increment each time;
counterVar.

Ideally I would like to be able to access the variables using
something to the effect of:-

Console.Writeline(var + counterVar);

counterVar++

Console.Writeline(var + counterVar);

using PHP I would achieve this using $var{$counterVar}
(to give another example).

I hope someone can shed some light onto whether or not this is
possible.

Thanks in advance

Jason Dunbar

Nov 16 '05 #3
Thanks for the suggestions folks.

On Mon, 27 Sep 2004 15:18:14 +0100, Jason Dunbar
<jason__D0T__dunbar__AT__intechnology__D0T__co__D0 Tuk> wrote:
Hi there..

I am wondering if it is possible to interpolate the value of a
variable to reference a variable to gain its value.

For example:-

if I have a series of variables:-

var01
var02
var03
var04

(I would arrange them into an array, but they are being generated via
form input)

Let's say I wanted to access these in order using a loop, I would
quite like to use a counter variable that I can increment each time;
counterVar.

Ideally I would like to be able to access the variables using
something to the effect of:-

Console.Writeline(var + counterVar);

counterVar++

Console.Writeline(var + counterVar);

using PHP I would achieve this using $var{$counterVar}
(to give another example).

I hope someone can shed some light onto whether or not this is
possible.

Thanks in advance

Jason Dunbar


Nov 16 '05 #4
"Jason Dunbar" <jason__D0T__dunbar__AT__intechnology__D0T__co__D0 Tuk>
wrote@
if I have a series of variables:-
var01, var02, var03, var04
(I would arrange them into an array, but they are
being generated via form input)


Surely the sane thing to do here is to convert them into an array.

string[] s = new string[4];

for (int i = 1; i <= 4; i++)
{
s[i] = ValueFromForm("var0" + i);
}

P.
Nov 16 '05 #5

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

Similar topics

1
by: Peter Horst | last post by:
I have a tiny custom 404 script I'm working on; I'd like to imitate the standard Apache 404 page insofar as I'd like "Apache/1.3.29 Server at www.example.com Port 80" to appear below my 404...
3
by: red | last post by:
within an object function, this code: $test2='test'; echo "$test"; $this->test2='test2'; echo "$this->test2\n"; produces this result: test2
7
by: bartek | last post by:
Hello, I've been pondering with this for quite some time now, and finally decided to ask here for suggestions. I'm kind of confused, actually... Maybe I'm thinking too much... Brain dump...
14
by: Charles Banas | last post by:
I'm not sure if this is the right place to ask about this, but I've seen several posts in the past regarding Akima's Bivariate Interpolations routines, and i'm wondering if someone can give me some...
3
by: Jonas Ernst | last post by:
Hi, Can somebody give me some hints how to do a line interpolation without using floating point arithemtics? The function shall do a linear interpolation between 2 points (line interp?) and...
8
by: Jerry | last post by:
I am a MySQL and PHP newbie. I am having trouble getting the $w variable in my code below passed to mysql. When I use the value of $w directly in the Where clause, the correct rows are returned....
10
by: John Passaniti | last post by:
(Note: This is not the same message I posted a week or so ago. The problem that prevented my previous attempt to work was a silly error in the template system I was using. This is a problem...
5
by: CarpeSkium | last post by:
I know I can use a variable in regular expressions. I want to use a regex to find something based on the beginning of the string. I am using yesterday's date to find all of my data from yesterday....
5
by: August Karlstrom | last post by:
Hi, Does anyone know the correct syntax to interpolate a class variable, $x say, inside a string? I tried "{self::$x}" but it produces the string {self::x}
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.