Your Universal Remote Control Center
RemoteCentral.com
Philips Pronto Professional Forum - View Post
Up level
Up level
The following page was printed from RemoteCentral.com:

Login:
Pass:
 
 

Original thread:
Post 8 made on Thursday August 12, 2010 at 00:37
Lyndel McGee
RC Moderator
Joined:
Posts:
August 2001
12,999
Then, I might suggest that you put nested arrays into a starting array and then build out your final array.

// we want to exclude 2, 3, 7-27(inclusive), 100, and 203.
var excludearraystart = [2,3,[7,27],100,203];
var excludearray = [];
var i,j,start,end,elem;

// this loop builds final array.
for (i=0;i{
elem = excludearraystart[i];
if (typeof(elem) === 'number')
excludearray.push(elem);
else if (elem instanceof Array) // See Flanagan and duck-typing for better check.
{
// extract start and end bounds from the array.
start = elem[0];
end = elem[1];
for (j = start; j excludearray.push(j);
}
}
// now, you can use excludearray as you did before.


Note that your channel increment could stand improvement such that channel is incremented to next valid channel instead of by 1.
while(excludearray.indexOf(channel) >= 0)
{
channel++;
if (channel > 999) channel = 1; // 999 is largest possible channel.
}
Lyndel McGee
Philips Pronto Addict/Beta Tester


Hosting Services by ipHouse