Author Topic: http driver  (Read 1367 times)

hpservertech

  • Jr. Member
  • **
  • Posts: 66
    • View Profile
http driver
« on: April 22, 2010, 11:04:29 am »
not sure if this is a bug or the way that I am doing a script.

Create a label
User script:
{c = http.RetrieveWebPage( "http://71.81.200.59/gett1.cgi" );
c = Number(c); // convert string received from web to a number
f = (c * 1.8) + 32;}°F

Script works, display shows numeric value.
What happens though is that the °F is placed on a new line.
Running: http.RetrieveWebPage( "http://71.81.200.59/gett1.cgi" ); in the script tester the same thing happens, there is a cursor on a 2nd line blicking in the results window.

I have used wget to pull the above page and it puts the results into a single line.

**URL above is internet accessible, so anyone can reach it right now.  It is going to a CAI WebControl deivce that does temp/humidity/input/output.
Current setup: Windows 7 Enterprise x86, x10 cm15a, dedicated master server, dedicated WHS for media

John Hughes

  • Administrator
  • Hero Member
  • *****
  • Posts: 2851
    • View Profile
    • Codecore Technologies
Re: http driver
« Reply #1 on: April 22, 2010, 12:04:00 pm »
My first guess would be that your label control is not large enough and your text is wrapping.

In the script editor, I'm not sure that the cursor blinking on the next line is an indication of anything.  It likely does that with something as simple as "return 1;".

To test your theory, try this in the script editor:

Code: [Select]
http.RetrieveWebPage( "http://71.81.200.59/gett1.cgi" ) + "°F";
John Hughes
Codecore Technologies

John Hughes

  • Administrator
  • Hero Member
  • *****
  • Posts: 2851
    • View Profile
    • Codecore Technologies
Re: http driver
« Reply #2 on: April 22, 2010, 12:07:34 pm »
Also keep in mind that your approach here is a little non-standard. Normally you would not use a full script as a label macro.  The label will run the script every 60 seconds. You would update a global variable using a rule for a timer event or better yet an event that fires whenever the temperature changes... and the label would just show the global variable.
John Hughes
Codecore Technologies

hpservertech

  • Jr. Member
  • **
  • Posts: 66
    • View Profile
Re: http driver
« Reply #3 on: April 22, 2010, 12:11:34 pm »
I went ahead and made the label 370x300.  I thought text size originally.  kept playing with the font & size, but always had the same results.  Font is currently set at 14pt.

Updated script shows 2 lines of text in box the image box as well as the script tester.

Understand I am not doing this in the most efficient manor.  This was just a simple way that I understood.  I'm still learning & reading.
Current setup: Windows 7 Enterprise x86, x10 cm15a, dedicated master server, dedicated WHS for media

John Hughes

  • Administrator
  • Hero Member
  • *****
  • Posts: 2851
    • View Profile
    • Codecore Technologies
Re: http driver
« Reply #4 on: April 22, 2010, 12:33:04 pm »
I think I see it... your script may not be returning what you think it is...

Try this:

Code: [Select]
{c = http.RetrieveWebPage( "http://71.81.200.59/gett1.cgi" );
c = Number(c); // convert string received from web to a number
f = (c * 1.8) + 32;
return f;
}°F
John Hughes
Codecore Technologies

John Hughes

  • Administrator
  • Hero Member
  • *****
  • Posts: 2851
    • View Profile
    • Codecore Technologies
Re: http driver
« Reply #5 on: April 22, 2010, 12:34:57 pm »
You may also want to format the returned value since I can see those decimal places getting out of hand...

Code: [Select]
{c = http.RetrieveWebPage( "http://71.81.200.59/gett1.cgi" );
c = Number(c); // convert string received from web to a number
f = (c * 1.8) + 32;
return f.ToString("##.#");
}°F
John Hughes
Codecore Technologies

hpservertech

  • Jr. Member
  • **
  • Posts: 66
    • View Profile
Re: http driver
« Reply #6 on: April 22, 2010, 02:44:11 pm »
That it!  Needed the return f

I went ahead and put the string in.  Have it dropping the decimal, I dont really need that precise.  but it is working now.  I had through that this really wasn't a bug, but just a problem with the way the script was doing things.

Thanks again.
Current setup: Windows 7 Enterprise x86, x10 cm15a, dedicated master server, dedicated WHS for media