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 Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

for command and variable variable names

Status
Not open for further replies.

JonnyPT

Programmer
Joined
Oct 27, 2004
Messages
21
Location
US
i have a small 5x6 matrix of textboxes with var names in this scheme
11 means first row first column
12 means first row second column
34 means third row fourth column...

i wanted to create a reset function to set them equal to 100 times the row number

i am not very fluent in actionscript, but i know a little, i tried to fill in with psudeo-PHP style coding, and came up with this.

Code:
//create a var "hundred"
var hundred = 0;
//define function
function reset(){
//for each column
	for(y=1;y<=5;y++){
//set hundred equal to 100 times the column number
		hundred = 100*y;
//for each row
		for(x=1;x<=6;x++){
//set the variable that has var x as the first digit and var y 
//as the second digit equal to the current value of the var hundred... 
//in php ${$x.$y} = $hundred
			{x+y} = hundred;
		}
	}
}
//apply the function
reset();

needless to say...it doesn't work
 
what exactly are you trying to do ???

have the values displayed in the text boxes changed or their x,y co-ordinates

or as monty python would say 'something completely different'

just cant tell from the question
 
basically {[red]x[/red]+[blue]y[/blue]} is supposed to be the variable name
when [red]x[/red]=[red]1[/red] and [blue]y[/blue]=[blue]3[/blue] then {[red]x[/red]+[blue]y[/blue]} should equal [red]1[/red][blue]3[/blue]
then i want the value of the text box with that variable name ([red]1[/red][blue]3[/blue] in this case) to be set to [blue]3[/blue]00 (which is 100 times [blue]3[/blue] (the value of var [blue]y[/blue])
 
it might be easier to understand this way,
the value of every text box in row 1 will be set to 100
the value of every text box in row 2 will be set to 200
the value of every text box in row 3 will be set to 300..
there are 6 rows total and 5 columns in each row

i could just put in code like this
Code:
function reset() {
     [red][b]1[/b][/red]1 = [red][b]1[/b][/red]00;
     [red][b]1[/b][/red]2 = [red][b]1[/b][/red]00;
     [red][b]1[/b][/red]3 = [red][b]1[/b][/red]00;
     [red][b]1[/b][/red]4 = [red][b]1[/b][/red]00;
     [red][b]1[/b][/red]5 = [red][b]1[/b][/red]00;
     [red][b]2[/b][/red]1 = [red][b]2[/b][/red]00;
     [red][b]2[/b][/red]2 = [red][b]2[/b][/red]00;
     [red][b]2[/b][/red]3 = [red][b]2[/b][/red]00;
     .....you should get the point
     [red][b]6[/b][/red]5 = [red][b]6[/b][/red]00;.....this would be the last one

}

but i want to replace that with 2 for() loops
 
something like this then

Code:
function reset(mult){
	for(i=1;i<7;i++){
		for(j=1;j<6;j++){
			this["i"+"j"] = i*mult;
		}
	}
}
reset(100);
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top