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:
Combine 2 Pronto scripts in 1 ?
This thread has 1 response. Displaying all posts.
Post 1 made on Sunday January 17, 2021 at 14:15
kapsreiter
Long Time Member
Joined:
Posts:
November 2006
47
sorry for my english

i have 2 working pronto scripts but find no way to get a script to a macro

so is there a way to combine this 2 scripts in 1 script block

i am not a programmer may be someone could edit it for me?

script 1
__________________________________
var socket = new TCPSocket(false);
var result="";


var JSON_on='{"on":true}';

function getInfos(commands)
{
socket.write('PUT /api/lVfthQzyz9ZbNsUyndnZT9WBBOQ852HY3fEcPUVg/groups/1/action HTTP/1.1\r\nHost: 10.0.0.2\r\nUser-Agent: ProntoTSU9600\r\nContent-Length: '+commands.length+'\r\n\r\n'+commands);

}

socket.onConnect = function()
{
getInfos(JSON_on);
};

socket.onData = function()
{

};

socket.onClose = function()
{
socket = null
}

socket.onIOerror = function() {
System.print("error");
try {
socket.close()
socket = null
} catch(e) {}
}

socket.connect('10.0.0.2', 80, 3000);

script 2
__________________________________
var result = "";
var socket = new TCPSocket(false);
var t1,t2,t3,t4,t5;
var event1,event2;
var descrip1, descrip2;

socket.onConnect = function()
{
socket.write("GET /relay/0?turn=on HTTP/1.0\r\n");
socket.write("Accept: */*\r\n");
socket.write("Host: 10.0.0.249\r\n");
socket.write("Connection: close\r\n");
socket.write("\r\n");
};
socket.onData = function()
{
//result += socket.read(5000,1000);

t0 = result.indexOf("class=\"time\">", 0)+13;
t10 = result.indexOf("/span>",t0)-1;
tijd1 = result.substring(t0,t10);

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

t4 = result.indexOf("class=\"description\">", t2)+20;
t5 = result.indexOf("/span>",t4)-1;

t6 = result.indexOf("class=\"event\">", t5)+14;
t7 = result.indexOf("/span>",t6)-1;
event2 = result.substring(t6,t7);
CF.widget("channel2").label=event2;

};


socket.onClose = function()
{
};


socket.onIOError = function(e)
{
};


if(socket.connected == false)
{
socket.connect('10.0.0.194', 80, 3000);
};
____________________________________


thank you tom
Post 2 made on Tuesday January 19, 2021 at 11:26
Lyndel McGee
RC Moderator
Joined:
Posts:
August 2001
12,767
Tom,

The first issue you will have is that you have 2 different scripts that use the same variable names: result and socket.

In order for you to be able to combine these, you'll need to modify the names.

The easiest is to change the 2 variable names in Script 1.

var socket1 = new TCPSocket(false);
var result1="";


var JSON_on='{"on":true}';

function getInfos(commands)
{
socket1.write('PUT /api/lVfthQzyz9ZbNsUyndnZT9WBBOQ852HY3fEcPUVg/groups/1/action HTTP/1.1\r\nHost: 10.0.0.2\r\nUser-Agent: ProntoTSU9600\r\nContent-Length: '+commands.length+'\r\n\r\n'+commands);

}

socket1.onConnect = function()
{
getInfos(JSON_on);
};

socket1.onData = function()
{

};

socket1.onClose = function()
{
socket1 = null
}

socket1.onIOerror = function() {
System.print("error");
try {
socket1.close()
socket1 = null
} catch(e) {}
}

socket1.connect('10.0.0.2', 80, 3000);


After you do this, you should be able to put the content of both scripts into the same page or activity script.
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