Dynamic Variable Reference
Posted: Thu Dec 25, 2008 6:35 pm
I need some help with this variable reference. First off, here is the code...
With this statement giving me the trouble...
I should probably use a FOR instead of WHILE with a counter, but one thing at a time, ya know? 
I have a delta# arrays for 14 different sites. The lex array is a numerical nearest neighbor list to search other sites for extra equipment. I have a for loop that calls this statement until the needed equipment has been found in another site. Delta#[1] is for tents. $r is a counter incremented each time to go to the next nearest neighbor in the list. I figured I would get it working for just one piece of equipment before I did the rest!
So basically, need to know how to reference delta(lex[nearestinlist])[tents]. Each time it's called, we check the next nearest neighbor. I know, complicated explanation. Please help me!
Code: Select all
//lexington
if($delta3[1] < 0) //tents needed?
{
//let the search begin
$r = 0;
while(r < 14)
{
if($'delta' . {$lex[$r])}[1] > 0) //extra tents exist
{
//will write this later
}
$r = $r + 1;
}
Code: Select all
if($'delta' . {$lex[$r])}[1] > 0)
I have a delta# arrays for 14 different sites. The lex array is a numerical nearest neighbor list to search other sites for extra equipment. I have a for loop that calls this statement until the needed equipment has been found in another site. Delta#[1] is for tents. $r is a counter incremented each time to go to the next nearest neighbor in the list. I figured I would get it working for just one piece of equipment before I did the rest!
So basically, need to know how to reference delta(lex[nearestinlist])[tents]. Each time it's called, we check the next nearest neighbor. I know, complicated explanation. Please help me!