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

Login:
Pass:
 
 

Topic:
How do I exclude certain numbers .
This thread has 7 replies. Displaying all posts.
Post 1 made on Monday August 9, 2010 at 18:06
alpha
Long Time Member
Joined:
Posts:
September 2003
258
I was looking for a way to exclude certain channel numbers from an activity I made called the Channel Blaster . For example. The channels numbers 15,19,35,48,52,53,54,80 through 92 and 100 through 320. The highest channel number could be 400. Here is a script I use without the exclusions. Would there be a way to add a panel for excluded chanels that are listed in the label ?

//  Channel  Blaster
// Rotate wheel to chnge the channel number.
//  This is placed on page
//  - - - - - - - - - - - - - - - - - - - - - - Button and Panel - - - - - - - - -

var highnumber = widget ("HIGHNUMBER") ;  // the highest channel # is in the label
// HIGHNUMBER is not seen. It is placed off to the side and only seen in editor .

var pb = widget ("PRESSBUTTON") ;  // button changes the channel to the label
// This button has a script to execute the actions based on the label displayed

//  - - - - - - - - - - - - - - - - - - - - - - VARIABLES - - - - - - - - - - - - -

var hnlabel = highnumber. label ;// this is number put  in the label for HIGHNUMBER

var channel = 002 ;  // this  will be the starting channel number

//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

pb.label = channel ;                // starts at 2 in label of button

function showchannel ( ) { pb.label = channel; } ;// changes label with wheel

// - - - - - - - - - - - -ROTARY WHEEL - - - - - - - - - - - - - - - - - - - - - -

onRotary =  function ( clicks )
     {
    showchannel ( ) ;     // changes the label as the wheel is spun

    if ( channel >= hnlabel )          //  when label reaches high number
        { defaultchannel  = 2 ; } ; //  it changes  to number 2

    if ( channel < 002 )                         //  when label reaches  number 2
        { channel= hnlabel ; } ;  //  it changes  to number the high number

    if (clicks > 1)
        { channel+=10 ; } ;  // up ten numbers

    if (clicks < -1)
        { channel-- ; } ;  // down one number
     } ;

//- - - - - - - - - - - - - - - - - - - - - - E N D  - - - - - - - - - - - - - - -



Project Boredom 2 is here. [Link: mediafire.com]
------------------------
Check Version 1 & 2 out in the files section.
Post 2 made on Monday August 9, 2010 at 22:01
gopronto
Senior Member
Joined:
Posts:
April 2008
1,453
Im no expert like Barry and lyndell, but im guess you would need to use an "Array"
Pronto still one of the best Wi-Fi Remotes,
www.ikonavs.co.nz and [Link: axiumcontrol.com] Axium Control
OP | Post 3 made on Monday August 9, 2010 at 22:46
alpha
Long Time Member
Joined:
Posts:
September 2003
258
I tried to create an array but I had problems.

var channelexclude = [30,52,53,54,55,56,90 ] ;

and then add to the onRotary function

if ( channel = channelexclude )
          {channel ++ : } ;

or ...
if ( channel == channelexclude )
          {channel ++ : } ;


 Sometimes 30,52,54,56 and 90 would be excluded. 53 and 55 would be shown.
If I used ...
var channelexclude = [30,52,100-200 ] ;
30,52 and 100 would be excluded but 101-200 were not.

I can't figure out how to exclude a chanel and goto the next unexcluded channel.
Project Boredom 2 is here. [Link: mediafire.com]
------------------------
Check Version 1 & 2 out in the files section.
Post 4 made on Tuesday August 10, 2010 at 00:05
gopronto
Senior Member
Joined:
Posts:
April 2008
1,453
is it not === , im sure some one will correct me on this :)
Pronto still one of the best Wi-Fi Remotes,
www.ikonavs.co.nz and [Link: axiumcontrol.com] Axium Control
Post 5 made on Tuesday August 10, 2010 at 03:25
buzz
Super Member
Joined:
Posts:
May 2003
4,371
var channelexclude = [30,52,100-200 ] ;


Results in a three element array with values 30, 52, -100

----

Edit:

I don't know what the project requirements might be, but I would be tempted to write includeChannel() and excludeChannel() functions that do all of the dirty work. These functions could be called as needed to give local context to channel navigation. These functions would also keep things neat and tidy for the programmer.

Syntax could be:

includeChannel( 23 );
excludeChannel( 23, 50, 225);
excludeChannel( 5, "10-20", 63, "200+");
includeChannel( sports, cartoons, shopping );  (each of these items is an array)


Note that ranges are quoted. This is required because a non quoted range will be executed as a simple calculation.

Last edited by buzz on August 10, 2010 22:59.
Post 6 made on Tuesday August 10, 2010 at 18:07
Lyndel McGee
RC Moderator
Joined:
Posts:
August 2001
12,994
Here's the logic you want if using an array:

var channel = 30;
var channelexclude = [30,52,53,54,55,56,90 ] ;

if (channelexclude.indexOf(channel) >= 0))
{
channel ++;
}



Note that you must put individual channels into the array as others have pointed out and not what you would think is a range (100-200).
Lyndel McGee
Philips Pronto Addict/Beta Tester
OP | Post 7 made on Wednesday August 11, 2010 at 18:48
alpha
Long Time Member
Joined:
Posts:
September 2003
258
I was trying to get away with out entering every channel for exclusion . I will use the idea of different categories ( arrays ) of channels . I did not have that in mind but I will try something with that . Lyndel , your example worked very well . I just have to figure out how to make it work in reverse. I will research the indexOf when I get a chance . 

Thanks for all the help.

Alpha.
Project Boredom 2 is here. [Link: mediafire.com]
------------------------
Check Version 1 & 2 out in the files section.
Post 8 made on Thursday August 12, 2010 at 00:37
Lyndel McGee
RC Moderator
Joined:
Posts:
August 2001
12,994
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


Jump to


Protected Feature Before you can reply to a message...
You must first register for a Remote Central user account - it's fast and free! Or, if you already have an account, please login now.

Please read the following: Unsolicited commercial advertisements are absolutely not permitted on this forum. Other private buy & sell messages should be posted to our Marketplace. For information on how to advertise your service or product click here. Remote Central reserves the right to remove or modify any post that is deemed inappropriate.

Hosting Services by ipHouse