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:
Prontoscript help
This thread has 3 replies. Displaying all posts.
Post 1 made on Sunday November 18, 2007 at 17:03
snelvuur
Long Time Member
Joined:
Posts:
November 2007
55
Hi all,

I managed to get some script to fetch data from a webpage and show it on my pronto. Also managed to only grab the parts i want. Here is a snippet:

t1 = result.indexOf("class=\"event\">",start)+14;
t2 = result.indexOf("/span>",t1)-1;
event1 = result.substring(t1,t2);
CF.widget("channel1").label=result.substring(t1,t2);

My problem is, that this will show the last found "event" from the html code, can i make it that it will match only the first record it finds, or even better all events with these results?

My other issue is when i have the string, its too long to show on the label on my pronto. But the label shows the line to the end of the label and the rest is not visible. Can i use some trimming that it would show the resulsts on say 3 lines or 4 lines depending on how big the line is? So the whole text will fit?

Thanks,
Eric
Post 2 made on Sunday November 18, 2007 at 18:48
Barry Gordon
Founding Member
Joined:
Posts:
August 2001
2,157
A couple of things to think about. Http data if large enough in size will come in blocked by the network. You need to make sure you are accumulating all of the blocks and concatenating them ontil the last block is received. then start searching.

With regard to editing the text to fit, you need to figure out what is the average character width of the font you are using since it is not published, nor is there a function available to yield the width of a string in pixels as there is in other systems.

A reasonable approximation can be had by using the letter make up from game Scrabble as the numbers of each letter is based on the distribution of letters in English text. Build a line with that distribution load it into a widget label and start shortening the width dimension of the widget. divide by the number of characters and you have a reasonable but not perfect average character width. If I remember right, in good font design, the letter "m" is supposed to be the average width of the characters or was it "n". I'd look it up but I gave my book on typography away.

You can then add \r\n at the appropriate points to cause the laebl to be multiple lines.

Hope that helps
OP | Post 3 made on Sunday November 18, 2007 at 19:05
snelvuur
Long Time Member
Joined:
Posts:
November 2007
55
I think it might be easier, to have some perl/php scripts do all the work. Then let the pronto grab that url instead. I understand what you are saying barry about the other things, my javascript aint up to speed. So i thought one could use the index number to found out the lenght of the string, then divide it in some sort.

Do you have any examples in which this is used, or some javascript commands that can aid me in my quest to seek out where no.. (hmm.. i watch to much t.v.) :-)
Post 4 made on Sunday November 18, 2007 at 20:12
Barry Gordon
Founding Member
Joined:
Posts:
August 2001
2,157
the length of a string is just stringname.length. I strongly suggest Flanagan's book "Java Script the definative guide". It is what I use as a reference.

The issue is knowing where to divide it. I do a similar thing to load freeform text (description of a DVD) into a large label and then allow it to scroll vertically. I do it by dividing up the text based on average character size, then installing each segment of the text always ending on a blank, into the elements of an array. I can the quickly populate a subset of the array into a label adding \r\n (CRLF) at the end of each element as I concatanate it into the label. Scrolling is then very fast and simple.


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