It is currently March 28th, 2024, 7:39 pm

Help with variables

Get help with creating, editing & fixing problems with skins
User avatar
Codger
Posts: 97
Joined: May 29th, 2017, 3:16 pm

Re: Help with variables

Post by Codger »

jsmorley wrote:A little hard for me to test, as my IP doesn't ever change, but I would think that using:

Code: Select all

[MeasureExtIP]
Measure=Plugin
Plugin=WebParser
Url=http://icanhazip.com 
RegExp="(?siU)^(.*)$"
StringIndex=1
UpdateRate=90
FinishAction=[!EnableMeasure MeasureCheck][!UpdateMeasure MeasureCheck][!CommandMeasure MeasureWebParseLocation "Update"]
And removing UpdateDivider=-1 from [MeaasureWebParseLocation]

Should do the trick.

That !CommandMeasure is needed since that [MeasureWebParseLocation] measure will have the default UpdateRate of 300 (10 minutes) and you want to override that and force a full "go out to the web" update when [MeasureEXtIP] finishes.
It did not work. It did not display any location at all. (It is supposed to be after the '@' at the bottom and should display on loadup whether IP changes or not.)

I thought it through. I moved !command to MeasureCheck because I wanted the location displayed on the IP change not every 90 seconds.

I removed the persistent line because keeping the previous ip between skin loads was actually counter productive. And came up with this:

Code: Select all

[MeasureExtIP]
Measure=Plugin
Plugin=WebParser
Url=http://icanhazip.com
RegExp="(?siU)^(.*)$"
StringIndex=1
UpdateRate=90
FinishAction=[!EnableMeasure MeasureCheck][!UpdateMeasure MeasureCheck]

[MeasureCheck]
Measure=Plugin
Plugin=WebParser
Url=[MeasureExtIP]
StringIndex=1
IfMatch=#IPLast#
IfNotMatchAction=[!SetVariable IPLast "[MeasureCheck]"][!UpdateMeasure "MeasureWebParseLocation"][!CommandMeasure MeasureWebParseLocation "Update"]
IfMatchMode=1
DynamicVariables=1
Disabled=1
Still did not work.

Even followed
And removing UpdateDivider=-1 from [MeaasureWebParseLocation]
though it seems like leaving it in would have it tun only when called which is what I want.

Not sure where I am going wrong. Does it display location on your end? Should on bootup even with static IP.
I think I have about one more pass in me today if you do. My head is starting to spin.

Thanks so much for the hand holding.
[hr][/hr][hr][/hr]
"If you are the smartest one in the room, you are in the wrong room."
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Help with variables

Post by balala »

That for sure is not the solution of your problems, but I just saw something wrong and wanted to clarify it.
Never, BUT NEVER, use something like ImageName=[color=#FF0000]@Resources\[/color]PIAGreen.png (as you did for example on the [PIAStatus] meter). Instead use ImageName=[color=#FF0000]#@#[/color]PIAGreen.png. We're referring to the @Resources folder using the #@# variable, instead of the @Resources name.

On the other hand, I'm not sure at all this will help, but maybe it worth a try. Add an OnChangeAction=[!CommandMeasure "MeasureWebParseLocation" "Update"] option to the [MeasureExtIP] measure. I recommend this because the IP is returned by the [MeasureExtIP] measure. When its value is changing, the [MeasureWebParseLocation] measure should be updated, I think. This will be done by the above OnChangeAction option.
User avatar
Codger
Posts: 97
Joined: May 29th, 2017, 3:16 pm

Re: Help with variables

Post by Codger »

Wanted to thank you for your help.
RM eventually locked up and crashed and once rerun the location started working again.
Relearned, yet again, the importance of backups. :confused:
Still can't quite get it to do what I want but I feel confident I can get sorted when I am fresh on Wednesday.
I think the problem is in the incestuousness of MeasureCheck calling itself, calling MeasureExtIP which also calls MeasureCheck. Seems like there is lots of room for hazard there.

As I say I get it sorted. Then I'll be back with questions of how to get more info from the WebParser page without calling the site again. :oops:

Thanks again.
Good Night
[hr][/hr][hr][/hr]
"If you are the smartest one in the room, you are in the wrong room."
User avatar
Codger
Posts: 97
Joined: May 29th, 2017, 3:16 pm

Re: Help with variables

Post by Codger »

balala wrote:That for sure is not the solution of your problems, but I just saw something wrong and wanted to clarify it.
Never, BUT NEVER, use something like ImageName=[color=#FF0000]@Resources\[/color]PIAGreen.png (as you did for example on the [PIAStatus] meter). Instead use ImageName=[color=#FF0000]#@#[/color]PIAGreen.png. We're referring to the @Resources folder using the #@# variable, instead of the @Resources name.
Not sure why it rates a 'Never Ever' status but making that change did force me to move my folders around into the standard layout. So thanks for that. :thumbup:
[hr][/hr][hr][/hr]
"If you are the smartest one in the room, you are in the wrong room."
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Help with variables

Post by jsmorley »

Codger wrote:Not sure why it rates a 'Never Ever' status but making that change did force me to move my folders around into the standard layout. So thanks for that. :thumbup:
The issue is that ImageName=@Resources\PIAGreen.png is a relative path, relative to the location of the skin .ini file. On the other hand, ImageName=#@#PIAGreen.png, or for the sake of organization ImageName=#@#Images\PIAGreen.png, defines the full path to the proper location for the @Resources folder, which is at the root config level of the skin. That might be the same thing, but it might well not.

If you put @Resources at any other level than the root config level, it will not function as designed, fonts and cursors won't be loaded, and all the cool kids will make fun of you...

While it might be strong to say using @Resources in a path is forbidden, it is certainly not recommended. It makes an assumption that might not be true, and can only lead to tears.

https://docs.rainmeter.net/manual/skins/resources-folder/

Note that all built-in path variables in Rainmeter, including #@#, already have a trailing "\" at the end of them, and while Rainmeter will forgive redundant slashes in paths, it's cleanest to keep that in mind.
User avatar
Codger
Posts: 97
Joined: May 29th, 2017, 3:16 pm

Re: Help with variables

Post by Codger »

I just wanted to give closure to the thread (really showing my age now) in case someone with my problem stumbles on to it.

Biggest problem seems to be that the attempts scrambled something in RM. Three times I reached a point that the skin would stop showing the town. Unloading and reloading would not fix it, but ending the rainmeter process and reloading returned things to normal.

Once I learned that returning to more or less what you suggested worked just as, with my new understanding, it seemed it would. Here is the final bits of the relevant parts.

Code: Select all

[MeasureExtIP]
Measure=Plugin
Plugin=WebParser
Url=http://icanhazip.com
RegExp="(?siU)^(.*)$"
StringIndex=1
UpdateRate=90
FinishAction=[!EnableMeasure MeasureCheck][!UpdateMeasure MeasureCheck]

[MeasureCheck]
Measure=Plugin
Plugin=WebParser
Url=[MeasureExtIP]
StringIndex=1
IfMatch=#IPLast#
IfNotMatchAction=[!SetVariable IPLast "[MeasureExtIP]"][!CommandMeasure MeasureWebParseLocation Update]
IfMatchMode=1
DynamicVariables=1
Disabled=1

[MeterExtIP]
Meter=String
MeasureName=MeasureExtIP
X=#BackPadding#
Y=15r
FontSize=10
StringStyle=Bold
FontColor=#PureYellow#,255
Text="Ext IP: %1"
and

Code: Select all

[MeasureWebParseLocation]
Measure=Plugin
Plugin=WebParser
URL=http://ipinfo.io/
RegExp=(?siU)City.*<a class="flag .*</a>\n(.*)</td>.*<td>Postal Code</td>.*<td>(.*)</td>

[MeasureLocation]
Measure=Plugin
Plugin=WebParser
URL=[MeasureWebParseLocation]
StringIndex=1
DecodeCharacterReference=1
RegExpSubstitute=1
Substitute="^\s+":""

[MeasureZipcode]
Measure=Plugin
Plugin=WebParser
URL=[MeasureWebParseLocation]
StringIndex=2

[MeterLocation]
Meter=String
MeasureName=MeasureLocation
X=2r
Y=69r
FontSize=11
StringStyle=Bold
FontColor=#PureYellow#,255
Text="@ %1"
DynamicVariables=1
UpdateDivider=5
Lessons learned: do not code after dinner, reload clean from time to time, make backups at good points.

Thanks for you patience and leading me to understand the problem rather than just providing the answer.
[hr][/hr][hr][/hr]
"If you are the smartest one in the room, you are in the wrong room."
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Help with variables

Post by jsmorley »

Codger wrote:I just wanted to give closure to the thread (really showing my age now) in case someone with my problem stumbles on to it.

Biggest problem seems to be that the attempts scrambled something in RM. Three times I reached a point that the skin would stop showing the town. Unloading and reloading would not fix it, but ending the rainmeter process and reloading returned things to normal.
Just for future reference, what you were likely getting is a known issue with WebParser. If you refresh a skin repeatedly and in short order, what can happen is that WebParser will "hang", and the only way to correct it is is exit Rainmeter, which causes Windows to clean up the now orphan / stuck WebParser.dll. If a "parent" application goes away, and a "child" dll process doesn't, that is inherently unstable, and Windows will automatically clean it up.

This happens because WebParser is a "threaded" process. Since it runs on it's own in a sense, outside of the main Rainmeter thread, when you do a refresh of the skin Rainmeter sends a message to the thread which "kills" it with extreme prejudice. This is normally fine, but if you do that repeatedly, in effect not letting the process "finish" going out and getting the target information from the web, but killing and restarting it over and over, it can and will get its knickers in a knot and hang. There is no error generated, Rainmeter itself can't tell WebParser is hung, and WebParser can't speak for itself because... it's hung. WebParser will just stop working in that skin.

I suspect it is the underlying Internet Explorer API calls that WebParser uses that causes this. That is why while we have other "threaded" plugins like FileView and RunCommand and others, we have never seen this behavior with them, no matter how you abuse them.

Generally this is going to happen when you are in the process of designing and testing a skin. That is when you are going to be hammering it with manual skin refreshes. Just keep that in mind, be a bit gentle with manual refreshes on skins with WebParser, and if it hangs, so be it, just restart Rainmeter.
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Help with variables

Post by balala »

Codger wrote:Biggest problem seems to be that the attempts scrambled something in RM. Three times I reached a point that the skin would stop showing the town. Unloading and reloading would not fix it, but ending the rainmeter process and reloading returned things to normal.
This is a very common and well known problem of the WebParser plugin, widely used in skins. Sometimes, randomly, it simply stops working. In such cases a restart of Rainmeter many times helps. Usually we don't get such problems with other plugins, just with the WebParser.

EDIT: Sorry jsmorley, I was late. Again...
User avatar
Codger
Posts: 97
Joined: May 29th, 2017, 3:16 pm

Re: Help with variables

Post by Codger »

That fits perfectly with what was happening and what I was doing (testing)
Even if you know how to adapt it's always nice to what and why as well.
Thanks for the explanations.

Embarrassingly stupid question: how do you turn off RM besides using the task manager? Seems like I'm missing something under my nose.
[hr][/hr][hr][/hr]
"If you are the smartest one in the room, you are in the wrong room."
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Help with variables

Post by balala »

Codger wrote:Embarrassingly stupid question: how do you turn off RM besides using the task manager? Seems like I'm missing something under my nose.
Using the !Quit bang.
But don't think any question is stupid: with Rainmeter (and not just) there is always something to be learned.