It is currently April 8th, 2020, 4:08 pm

Some help with coding.

Help with creating, editing & fixing problems with skins
User avatar
Yincognito
Posts: 1152
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Some help with coding.

Post by Yincognito »

JamX wrote:
March 21st, 2020, 3:06 pm
still I have 1 strange item left which I can not explain.
When The VPN is ON and I refresh the skin the MeasureCurrentLatitude and MeasureCurrentLongitude display the lat and long of the variables I've declared. That's OK.
When I turn VPN OFF MeasureCurrentLatitude and MeasureCurrentLongitude get the values VPN lat and Long.

See movie: http://www.filefactory.com/file/7j43cn8eya7p/Project.mp4

Here is the skin with meters.
weather_.rmskin
Unfortunately, I have no way of testing, but you can try to add an IfMatchMode=1 to the IfMatch in [MeasureAdapter] from the WeatherComVariables - Auto Locate.inc file. This would execute the IfMatch test on every update of the measure, instead of just once at skin load/refresh as it is now.

Also, I'm not sure the weather would update in the current form of the bangs in the IfMatch. WebParser measures update their web content only on a command to update and not on simple [!UpdateMeasure ...] bangs.
User avatar
balala
Rainmeter Sage
Posts: 10094
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Some help with coding.

Post by balala »

Yincognito wrote:
March 21st, 2020, 3:48 pm
Unfortunately, I have no way of testing, but you can try to add an IfMatchMode=1 to the IfMatch in [MeasureAdapter] from the WeatherComVariables - Auto Locate.inc file. This would execute the IfMatch test on every update of the measure, instead of just once at skin load/refresh as it is now.

Also, I'm not sure the weather would update in the current form of the bangs in the IfMatch. WebParser measures update their web content only on a command to update and not on simple [!UpdateMeasure ...] bangs.
I can't test either, however I suppose Yincognito is right: when you set a new value for the urlcurrent and urlforecast variables, you have to:
  • Update the appropriate parent WebParser measures with !UpdateMeasure bangs, to get them using the just set new value of the variables.
  • Update them as well, to get them go outside to internet and acquire the needed information.
You can do this by adding some bangs to the IfMatchAction and IfNotMatchAction options of the [MeasureAdapter] measure within the Weather_TWC - Auto Locate\@Resources\WeatherComVariables - Auto Locate.inc file:

Code: Select all

[MeasureAdapter]
Measure=Plugin
Plugin=SysInfo
SysInfoType=ADAPTER_DESCRIPTION
SysInfoData=Best
IfMatch=GOOSEVPN
IfMatchAction=[!SetVariable VPNOn "1"][!UpDateMeasure "MeasureCurrentLatitude"][!UpDateMeasure "MeasureCurrentLongitude"][!SetVariable URLCurrent "https://weather.com/#Language#/weather/today/l/[MeasureCurrentLatitude],[MeasureCurrentLongitude]"][!EnableMeasure "@CurrentAll"][!SetVariable URLForecast "https://weather.com/#Language#/weather/tenday/l/[MeasureCurrentLatitude],[MeasureCurrentLongitude]"][!EnableMeasure "@ForecastAll"][!UpdateMeasure "@CurrentAll"][!UpdateMeasure "@ForecastAll"][!CommandMeasure "@CurrentAll" "Update"][!CommandMeasure "@ForecastAll" "Update"]
IfNotMatchAction=[!SetVariable VPNOn "0"][!UpDateMeasure "MeasureCurrentLatitude"][!UpDateMeasure "MeasureCurrentLongitude"][!SetVariable URLCurrent "https://weather.com/#Language#/weather/today/l/[MeasureCurrentLatitude],[MeasureCurrentLongitude]"][!EnableMeasure "@CurrentAll"][!SetVariable URLForecast "https://weather.com/#Language#/weather/tenday/l/[MeasureCurrentLatitude],[MeasureCurrentLongitude]"][!EnableMeasure "@ForecastAll"][!UpdateMeasure "@CurrentAll"][!UpdateMeasure "@ForecastAll"][!CommandMeasure "@CurrentAll" "Update"][!CommandMeasure "@ForecastAll" "Update"]
DynamicVariables=1
See the newly added bangs at the end of both options, IfMatchAction and IfNotMatchAction.
The IfMatchMode option is not needed as far as I can tell.
User avatar
JamX
Posts: 108
Joined: October 4th, 2019, 2:46 pm

Re: Some help with coding.

Post by JamX »

now nothing is happening anymore.
After restart rainmeter it crashes

I have removed the whole automatic lat and long measures.
It's easier and quicker to manually change the url's (use variables)

Thanks for the effort guy's.
User avatar
balala
Rainmeter Sage
Posts: 10094
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Some help with coding.

Post by balala »

JamX wrote:
March 21st, 2020, 4:49 pm
now nothing is happening anymore.
What the "nothing is happening" does mean?
JamX wrote:
March 21st, 2020, 4:49 pm
After restart rainmeter it crashes
Post your last, not working code, please.
User avatar
JamX
Posts: 108
Joined: October 4th, 2019, 2:46 pm

Re: Some help with coding.

Post by JamX »

weather_.rmskin

Code: Select all

[Variables]
Language=en-GB
UpdateRate=600

;--- Lat & Long for Landgraaf NL ---
Latitude=50.8871
Longitude=6.0116

;--- Lat & Long for Kabbelaarsbank NL ---
;Latitude=51.7563
;Longitude=3.8402

;--- URL's ---
;URLCurrent = "https://weather.com/#Language#/weather/today/l/#Latitude#,#Longitude#"
;URLForecast = "https://weather.com/#Language#/weather/tenday/l/#Latitude#,#Longitude#"

[MeasureLocationIP]
Measure=WebParser
URL=https://ipapi.co/json
RegExp="(?siU)"city": "(.*)".*"region": "(.*)".*"country_name": "(.*)",.*"latitude": (.*),.*"longitude": (.*),.*"
UpdateRate=#UpdateRate#
FinishAction=[!UpdateMeasureGroup GeocodeGroup]
DynamicVariables=1

[MeasureLatitude]
Group=GeocodeGroup
Measure=WebParser
URL=[MeasureLocationIP]
StringIndex=4
RegExpSubstitute=1
Substitute="^$":"#Latitude#"

[MeasureLongitude]
Group=GeocodeGroup
Measure=WebParser
URL=[MeasureLocationIP]
StringIndex=5
RegExpSubstitute=1
Substitute="^$":"#Longitude#"

[MeasureAdapter]
Measure=Plugin
Plugin=SysInfo
SysInfoType=ADAPTER_DESCRIPTION
SysInfoData=Best
DynamicVariables=1
IfMatch=GOOSEVPN
IfMatchAction=[!SetVariable VPNOn "1"][!UpDateMeasure "MeasureCurrentLatitude"][!UpDateMeasure "MeasureCurrentLongitude"][!SetVariable URLCurrent "https://weather.com/#Language#/weather/today/l/[MeasureCurrentLatitude],[MeasureCurrentLongitude]"][!SetVariable URLForecast "https://weather.com/#Language#/weather/tenday/l/[MeasureCurrentLatitude],[MeasureCurrentLongitude]"][!CommandMeasure "@CurrentAll" "Update"][!CommandMeasure "@ForecastAll" "Update"]
IfNotMatchAction=[!SetVariable VPNOn "0"][!UpDateMeasure "MeasureCurrentLatitude"][!UpDateMeasure "MeasureCurrentLongitude"][!SetVariable URLCurrent "https://weather.com/#Language#/weather/today/l/[MeasureCurrentLatitude],[MeasureCurrentLongitude]"][!SetVariable URLForecast "https://weather.com/#Language#/weather/tenday/l/[MeasureCurrentLatitude],[MeasureCurrentLongitude]"][!CommandMeasure "@CurrentAll" "Update"][!CommandMeasure "@ForecastAll" "Update"]

[MeasureCurrentLatitude]
Measure=Calc
Formula=(1 - #VPNOn#) * [MeasureLatitude] + (#VPNOn#  * #Latitude# )
DynamicVariables=1

[MeasureCurrentLongitude]
Measure=Calc
Formula=(1 - #VPNOn#) * [MeasureLongitude] + (#VPNOn#  * #Longitude# )
DynamicVariables=1
After 4 time stopping rainmeter via taskmng after crash it works but when I manualy refresh again it crashes again.

I have removed [!EnableMeasure "@CurrentAll"][!EnableMeasure "@ForeCastAll"] and also the Disabled=1 command corresponding in the WeatherComCurrent and WeathetComForecast inc files
I have removed [!UpdateMeasure "@CurrentAll"][!UpdateMeasure "@ForecastAll"] since
[!CommandMeasure "@CurrentAll" "Update"][!CommandMeasure "@ForecastAll" "Update"] will do the same and now it does NOT crash anymore.

Only issue still left is:
When the VPN is OFF and then I load/refresh the skin and all is OK
When the VPN is ON and then I load/refresh the skin and it seems to be OK, but when I turn VPN OFF the MeasureLatitude and MeasureLongitude are still coming from the VPN Location because Rainmeter measures these while the VPN was turned ON at start.
After the next update cycle of MeasureLocationIP I see the correct location lat and long, but because the MeasureAdaptor did not change the skin also did not change/update.

So I tried: OnChangeAction=[!CommandMeasure "MeasureLocationIP" "Update"] to Update the MeasureLocationIP directly after a change in Adapter but still I get the VPN lat and long
You do not have the required permissions to view the files attached to this post.
User avatar
balala
Rainmeter Sage
Posts: 10094
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Some help with coding.

Post by balala »

JamX wrote:
March 21st, 2020, 10:58 pm
I have removed [!EnableMeasure "@CurrentAll"][!EnableMeasure "@ForeCastAll"] and also the Disabled=1 command corresponding in the WeatherComCurrent and WeathetComForecast inc files
I have removed [!UpdateMeasure "@CurrentAll"][!UpdateMeasure "@ForecastAll"] since
[!CommandMeasure "@CurrentAll" "Update"][!CommandMeasure "@ForecastAll" "Update"] will do the same and now it does NOT crash anymore.
Sorry for the troubles I've created with my last advice.
User avatar
JamX
Posts: 108
Joined: October 4th, 2019, 2:46 pm

Re: Some help with coding.

Post by JamX »

No worry Balala,

Now I only have to find a solution for the last issue:
Only issue still left is:
When the VPN is OFF and then I load/refresh the skin and all is OK
When the VPN is ON and then I load/refresh the skin and it seems to be OK, but when I turn VPN OFF the MeasureLatitude and MeasureLongitude are still coming from the VPN Location because Rainmeter measures these while the VPN was turned ON at start.
After the next update cycle of MeasureLocationIP I see the correct location lat and long, but because the MeasureAdaptor did not change the skin also did not change/update.

So I tried: OnChangeAction=[!CommandMeasure "MeasureLocationIP" "Update"] to Update the MeasureLocationIP directly after a change in Adapter but still I get the VPN lat and long