View Single Post
Old Oct 11th, 2007, 4:45 AM   #1
dpsleep
Newbie
 
Join Date: May 2006
Posts: 16
Rep Power: 0 dpsleep is on a distinguished road
compile a var name from another var

i have a script that holds the functions for a desklet. the desklet is to be ran in a program called avedesk. ultimately this block of code is meant to first check for the next side to flip to, then check if that side is enabled, then switch to it if it is, if its not, goto the next side and check it.

the variables of chk0-chk4 are ether true or false, true meaning the side is enabled false meaning it isn't and to skip it.

side is the current active side of the desklet

the newside stuff is just telling it if the current side is not the last side add one, else goto the first side.

then we got the while loop

now the problem im having is that im just starting js as this desklet program requires it. so i don't know much about the syntax and have been trying to get by on frequent Google searches.

the part im having trouble with is
if(newside == i && ("chk" + i) == 'true'){

what im trying to do is have the var i from the loop be added after chk so that if i == 2 it work read out to:
if(newside == i && ("ch" + i) == 'true'){
if(newside == i && chk2 == 'true'){

this is the best way i could come up with to get the reaction i want, i just don't know how to make the two add together.

function flipnext(){
	var chk0 = this.parameters('radarchk1');
	var chk1 = this.parameters('radarchk2');
	var chk2 = this.parameters('radarchk3');
	var chk3 = this.parameters('radarchk4');
	var chk4 = this.parameters('radarchk5');
	side = desklet.GetcurrentSide();
	if(side < 4){
		newside = side + 1
	}else{
		newside = 1
	}
	i = 0
	while(i < 5){
		if(newside == i && ("chk" + i) == 'true'){
			desklet.FlipTo(i);
			alert(i);
		}else if(("chk" + i) == 'false'){
			newside + 1
		}
	i++
	}
}

sorry if this has been solved before, i didn't know what to call it so i didn't really know what to search for. any help on this method or maybe an alternative method would be greatly appreciated. thanks.
dpsleep is offline   Reply With Quote