It is currently April 25th, 2024, 9:24 am

Unorthodox @Include without refreshing main skin

Get help with creating, editing & fixing problems with skins
User avatar
Yincognito
Rainmeter Sage
Posts: 7157
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Unorthodox @Include without refreshing main skin

Post by Yincognito »

Basic @Include file, placed in the main skin's @Resources folder:

Code: Select all

[MS_ExternalString]
String=aaa
Basic main skin:

Code: Select all

[Rainmeter]
AccurateText=1
Update=1000
DynamicWindowSize=1

[MS_ExternalString]
Measure=String
@IncludeExternalString=#@#ExternalString.inc
UpdateDivider=-1
DynamicVariables=1

[MS_SourceString]
Measure=String
String="This skin is trying to include a part of a measure that is updated without refreshing the main skin"
DynamicVariables=1

[MS_ResultString]
Measure=String
String="Click on this skin to write another value in the include file"
DynamicVariables=1

[MT_Test]
Meter=STRING
SolidColor=64,64,64,255
FontColor=255,255,255,255
MeasureName=MS_SourceString
MeasureName2=MS_ResultString
Text="Source:#CRLF#%1#CRLF##CRLF#Result:#CRLF#%2"
LeftMouseUpAction=[!WriteKeyValue MS_ExternalString String "bbb" "#@#ExternalString.inc"][!UpdateMeasure "MS_ExternalString"]
DynamicVariables=1
I'm trying to update some data (the String option of [MS_ExternalString]) in the skin using an @Include statetement when left clicking on the meter, but without refreshing the main skin. I know it's a strange method, but can this be done?
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
User avatar
jsmorley
Developer
Posts: 22629
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Unorthodox @Include without refreshing main skin

Post by jsmorley »

No, .inc files are only read when the skin is refreshed.

P.S. If there is a conflict with a [SectionName] between a .inc file and the skin, it will depend a bit on where you put the @Include option in the skin, but generally speaking, any options defined in the skin will override any options in the .inc file.
If there is a conflict - that is, if the same section exists in more than one file - Rainmeter will treat whichever one comes first in the ordering as the "real" section. Any options on the later instances will be added to the first one, and otherwise the later instances are simply ignored. If there are different values given for the same key, the last value is taken. Unlike new sections, options on pre-existing sections are added in their original order, so the calling section may overwrite values from the included file if they are placed below the @include statement.
User avatar
jsmorley
Developer
Posts: 22629
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Unorthodox @Include without refreshing main skin

Post by jsmorley »

So if you have this .inc:

Code: Select all

[Measure1]
String=From the .inc

If you have this skin:

Code: Select all

[Rainmeter]
Update=900
DynamicWindowSize=1
AccurateText=1

@Include=#@#Test.inc

[Measure1]
Measure=String
String=From the skin

[Meter1]
Meter=String
MeasureName=Measure1
FontSize=11
FontWeight=400
FontColor=255,255,255,255
SolidColor=47,47,47,255
Padding=5,5,5,5
AntiAlias=1
The result is "From the skin"


If you have this skin:

Code: Select all

[Rainmeter]
Update=900
DynamicWindowSize=1
AccurateText=1

[Measure1]
Measure=String
String=From the skin

@Include=#@#Test.inc

[Meter1]
Meter=String
MeasureName=Measure1
FontSize=11
FontWeight=400
FontColor=255,255,255,255
SolidColor=47,47,47,255
Padding=5,5,5,5
AntiAlias=1
The result is "From the .inc"
User avatar
jsmorley
Developer
Posts: 22629
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Unorthodox @Include without refreshing main skin

Post by jsmorley »

But in any case, any external change you make to a .inc file will not be recognized unless the skin is refreshed, which is the only time .inc files are read.
User avatar
Yincognito
Rainmeter Sage
Posts: 7157
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Unorthodox @Include without refreshing main skin

Post by Yincognito »

jsmorley wrote: March 15th, 2019, 2:09 pmNo, .inc files are only read when the skin is refreshed.
Got it.
jsmorley wrote: March 15th, 2019, 2:09 pmP.S. If there is a conflict with a [SectionName] between a .inc file and the skin, it will depend a bit on where you put the @Include option in the skin, but generally speaking, any options defined in the skin will override any options in the .inc file.
Yeah, I know, but due to how Rainmeter's !WriteKeyValue works, there needs to be a section, an option and so on in the file that is being written to, so that was a given; also, the section name was (probably?) needed in the main skin as well. Maybe I'm wrong, but regarding the name conflict, there doesn't seem to be one if the section name in both the main skin and the include file is [Variables] - I mean, I remember running into a problem when in my obsession with shortening the code I tried to delete the [Variables] line from one of them, so I concluded that in this case, the section name must be present in both files... correct me if I'm wrong.

Anyway, it's not a big deal, I was, like always, exploring my alternatives. Currently I do the process above using WebParser measures on a local file, and it works fine (aside from the fact that I need to stop reloading the parsed file as often as I currently do).
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
User avatar
jsmorley
Developer
Posts: 22629
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Unorthodox @Include without refreshing main skin

Post by jsmorley »

Of course as usual, I have no idea what you are trying to accomplish.

Did you trying something like:

Code: Select all

[Variables]
StringValue=From the .inc

Code: Select all

[Rainmeter]
Update=1000
DynamicWindowSize=1
AccurateText=1

[Variables]
@Include=#@#Test.inc
OriginalValue=#StringValue#
NewValue=#StringValue#

[Measure1]
Measure=String
String=#NewValue#
DynamicVariables=1

[Meter1]
Meter=String
MeasureName=Measure1
FontSize=11
FontWeight=400
FontColor=255,255,255,255
SolidColor=47,47,47,255
Padding=5,5,5,5
AntiAlias=1
LeftMouseUpAction=[!SetVariable NewValue "From the skin"][!UpdateMeter *][!Redraw]
RightMouseUpAction=[!SetVariable NewValue "#OriginalValue#"][!UpdateMeter *][!Redraw]
User avatar
jsmorley
Developer
Posts: 22629
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Unorthodox @Include without refreshing main skin

Post by jsmorley »

Yincognito wrote: March 15th, 2019, 2:28 pm Yeah, I know, but due to how Rainmeter's !WriteKeyValue works, there needs to be a section, an option and so on in the file that is being written to, so that was a given; also, the section name was (probably?) needed in the main skin as well. Maybe I'm wrong, but regarding the name conflict, there doesn't seem to be one if the section name in both the main skin and the include file is [Variables] - I mean, I remember running into a problem when in my obsession with shortening the code I tried to delete the [Variables] line from one of them, so I concluded that in this case, the section name must be present in both files... correct me if I'm wrong.
Correct. Any option defined in the .inc file must be associated with a [SectonName] in the .inc file. There can be no "orphan" option in the .inc file, as it will ignore them.
User avatar
Yincognito
Rainmeter Sage
Posts: 7157
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Unorthodox @Include without refreshing main skin

Post by Yincognito »

jsmorley wrote: March 15th, 2019, 2:29 pmOf course as usual, I have no idea what you are trying to accomplish.
Yes, I know, I'm an enigma to you, but can't say I dislike that though. :rofl:
My goal is trying to load the links of the visited feed items from an external file - nothing fancy. As explained in my previous reply, I'm successfully doing it using WebParser measures to parse the local file where I store those links, and I was looking for alternatives that would minimize the amount of memory used to store those strings (i.e. avoid them being stored twice, basically).

The file looks something like (I write into it using !WriteKeyValue, but I currently read from it using WebParser, not an @Include):

Code: Select all

; Stores the links of up to (Feed Limit x Feed Limit) visited feeds, in order to change the Feeds skin's title color based on the feed's read status.
; VisitedLinkIndex (initially -1) is the index of the last written visited link, and it endlessly cycles between 0 and (Feed Limit x Feed Limit - 1). 

[Variables]
VisitedLinkIndex=0
VisitedLink0=https://www.cnn.com/2019/03/14/europe/jan-kuciak-murder-marian-kocner-ordered-killing-intl/index.html
VisitedLink1=https://www.cnn.com/collections/intl-ethiopian-airlines-crash/
VisitedLink2=https://www.cnn.com/2019/03/14/us/winter-storm-blizzard-thursday-wxc/index.html
Because I have to do either a WebParser RegExp (or an IfMatch in the measure, if I wouldn't use WebParser) to check if the link of the current feed item is present in the list from the file, the visited link strings have to be "stored" in a measure (so that I can attach those options to it). The problem is that both WebParser and "loading" the strings using variables create "duplicates", as all or a part of those strings are stored in both the WebParser parent and the corresponding child(ren), or in both the variable and the measure that I assign that variable to in its String option. This is why I tried this unorthodox approach of loading an entire String measure directly in an @Include, bypassing the need to have an "intermediary" (like a variable, a WebParser parent, etc). Hopefully this make things more clear now... ;-)
jsmorley wrote: March 15th, 2019, 2:29 pmDid you trying something like...
That leads to pretty much having the included content stored twice, as explained above.
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth