Page 1 of 1
How to put beaufort text into banner.php?
Posted: Sat 23 Mar 2013 7:46 am
by William Grimsley
Hi Steve/others,
I've been trying to put beaufort text instead of beaufort number into the banner.php file.
Currently, I have the beaufort number showing.
In the cvalues area of the banner.php, I currently have this:
Code: Select all
// Current field names (matches tag fields) used
$SITE['cvalues'] = array(
"date","time","temp","hum","dew","wspeed","wgust","avgbearing","rrate",
"rfall","press","wdir","beaufort","windunit","tempunit","pressunit","rainunit",
"windrun","presstrend","rmonth","ryear","rfallY","intemp","inhum","wchill",
"temptrendval","tempTH","TtempTH","tempTL","TtempTL",
"windTM","TwindTM","wgustTM","TwgustTM",
"pressTH","TpressTH","pressTL","TpressTL",
"cversion","cbuild");
I tried changing:
To (I had put the <#beaudesc> web tag in the realtime.txt file):
But, that made all the other units except humidity display different units.
Please can someone help?
Thanks,
William
Re: How to put beaufort text into banner.php?
Posted: Sat 23 Mar 2013 9:12 am
by steve
I suspect it's because the beaufort description can be more than one word, so can get parsed as separate items. Try putting quotes around the web tag in your custom realtime.txt file - "<#beaudesc>". I don't know whether that will work because I don't know enough about the PHP "explode" function (which splits the line up).
If it doesn't work, you could change the delimeter in your realtime.txt file to something like "|" instead of space, and then change the code in banner.php:
Change
// Read data into array
$DATA = get_raw($SITE['hloc'] . $SITE['datafile'],' ');
to
// Read data into array
$DATA = get_raw($SITE['hloc'] . $SITE['datafile'],'|');
Anything else which uses your custom realtime.txt file would have to cope with that change too, of course.
Re: How to put beaufort text into banner.php?
Posted: Sat 23 Mar 2013 9:38 am
by William Grimsley
Hi Steve,
Ok, it looks like what you said about the banner.php file, works. But, now my realtime.txt file has stopped updating.
Thanks for your help,
William
Re: How to put beaufort text into banner.php?
Posted: Sat 23 Mar 2013 9:50 am
by steve
A possibly better way occurs to me: go back to using the beaufort number, put an array of descriptions in the PHP, and use the number to index the array.
Re: How to put beaufort text into banner.php?
Posted: Sat 23 Mar 2013 9:55 am
by William Grimsley
steve wrote:A possibly better way occurs to me: go back to using the beaufort number, put an array of descriptions in the PHP, and use the number to index the array.

Re: How to put beaufort text into banner.php?
Posted: Sat 23 Mar 2013 9:59 am
by William Grimsley
Ok, this what I have changed back to, so far.
In the realtime.txt file:
Code: Select all
<#date format=dd/mm/yy> <#timehhmmss> <#temp> <#hum>% <#dew> <#wspeed> <#wlatest> <#bearing> <#rrate> <#rfall> <#press> <#currentwdir> <#beaufortnumber> <#windunit> <#tempunitnodeg> <#pressunit> <#rainunit> <#windrun> <#presstrendval> <#rmonth> <#ryear> <#rfallY> <#intemp> <#inhum> <#wchill> <#temptrend> <#tempTH> <#TtempTH> <#tempTL> <#TtempTL> <#windTM> <#TwindTM> <#wgustTM> <#TwgustTM> <#pressTH> <#TpressTH> <#pressTL> <#TpressTL> <#version> <#build> <#wgust> <#heatindex> <#humidex> <#UV> <#ET> <#SolarRad> <#avgbearing> <#rhour> <#forecastnumber> <#isdaylight> <#SensorContactLost> <#wdir> <#cloudbasevalue> <#cloudbaseunit> <#apptemp> <#SunshineHours> <#CurrentSolarMax> <#IsSunny>
In the banner.php file:
Code: Select all
$DATA = get_raw($SITE['hloc'] . $SITE['datafile'],' ');
And:
Code: Select all
$SITE['cvalues'] = array(
"date","time","temp","hum","dew","wspeed","wgust","avgbearing","rrate",
"rfall","press","wdir","beaufort","windunit","tempunit","pressunit","rainunit",
"windrun","presstrend","rmonth","ryear","rfallY","intemp","inhum","wchill",
"temptrendval","tempTH","TtempTH","tempTL","TtempTL",
"windTM","TwindTM","wgustTM","TwgustTM",
"pressTH","TpressTH","pressTL","TpressTL",
"cversion","cbuild");
And:
Now, what do I do?
Re: How to put beaufort text into banner.php?
Posted: Sat 23 Mar 2013 10:23 am
by beteljuice
You could try posting in the banner thread, or you could try doing what Steve said ....
Declare a descriptive array
Code: Select all
/* Beaufort 0 to 12 in array */
$langBeaufort = Array (
"Calm", "Light Air", "Light Breeze", "Gentle Breeze", "Moderate Breeze", "Fresh Breeze",
"Strong Breeze", "Near Gale", "Gale", "STRONG GALE", "STORM",
"VIOLENT STORM", "HURRICANE"
);
// then your 'look-up'
$text = $langBeaufort[ret_value("beaufort")];
Re: How to put beaufort text into banner.php?
Posted: Sat 23 Mar 2013 10:29 am
by William Grimsley
beteljuice wrote:You could try posting in the banner thread, or you could try doing what Steve said ....
Declare a descriptive array
Code: Select all
$langBeaufort = Array (
"Calm", "Light Air", "Light Breeze", "Gentle Breeze", "Moderate Breeze", "Fresh Breeze",
"Strong Breeze", "Near Gale", "Gale", "STRONG GALE", "STORM",
"VIOLENT STORM", "HURRICANE"
);
// then your 'look-up'
$text = $langBeaufort[ret_value("beaufort")];
Hi beteljuice,
Thanks very much! Your fix worked!
All I've done is changed:
Code: Select all
$langBeaufort = Array (
"Calm", "Light Air", "Light Breeze", "Gentle Breeze", "Moderate Breeze", "Fresh Breeze",
"Strong Breeze", "Near Gale", "Gale", "STRONG GALE", "STORM",
"VIOLENT STORM", "HURRICANE"
);
To:
Code: Select all
/* Beaufort 0 to 12 in array */
$langBeaufort = Array (
"Calm", "Light air", "Light breeze", "Gentle breeze", "Moderate breeze", "Fresh breeze",
"Strong breeze", "Near gale", "Gale", "Strong gale", "Storm",
"Violent storm", "Hurricane"
);
So, that the beaufort scale texts match up with the Cumulus beaufort scale texts!
Thanks,
William
Re: How to put beaufort text into banner.php?
Posted: Sat 23 Mar 2013 12:00 pm
by beteljuice
The capitalization of the last four descriptions was to reinforce their severity.
ie. Don't go out and batten down the hatches !