It is currently March 29th, 2024, 1:08 pm

I want to reduce the number of codes and meters.

Get help with creating, editing & fixing problems with skins
gkmaz9
Posts: 67
Joined: August 26th, 2019, 10:42 am

I want to reduce the number of codes and meters.

Post by gkmaz9 »

My skills are improving little by little because of you who help me. But again I was in trouble. Please help me

I made this
1. I extract all words from a text file, And list them in line. (Using WebParser, meter=string)
2. When I click a extracting word, the word is written in new text file (using !WriteKeyValue)

It works fine, but the code is too long.
I would like to ask if there is a way to drastically reduce it.

example1. I want to reduce the repeated code.(I want 100 StringIndex)

Code: Select all

RegExp=(?siU)](.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\.....
example2. I want to reduce the number of repeating meters.

Code: Select all

[AA0001]
Measure=Plugin
Plugin=Plugins\WebParser.dll
~
[AA0100]
Measure=Plugin
Plugin=Plugins\WebParser.dll

example3. I want to reduce the number of repeating meters.
However, the number inside the meter also increases by one.

Code: Select all

[Output1]
meter=String
MeasureName=AA0001
DynamicVariables = 1 
LeftMouseUpAction=[!CommandMeasure "OutPutR1" "ExecuteBatch 1"][!RainmeterRedraw]
~
[Output100]
meter=String
MeasureName=AA0100
DynamicVariables = 1 
LeftMouseUpAction=[!CommandMeasure "OutPutR100" "ExecuteBatch 1"][!RainmeterRedraw]


Summary version of the actual skin for how it works
(I've cut down parts for explanation and I'm not sure if it works.)

Code: Select all

[Rainmeter]
Update=100
DynamicWindowSize=1


[Metadata]
XXXXX

[Variables]
MyFile=file://C:\Users\USER\Documents\Rainmeter\Skins\Eng\@Resources\TXT.inc


LogMax=1000
LogNum=0
-3=
-2=
-1=
0=


-[WebPhaser]---------------------------------------------------------------------------------------------------

[AA0001]
Measure=Plugin
Plugin=Plugins\WebParser.dll
Url=#MyFile#
RegExp=(?siU)](.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (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.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)
StringIndex=2
RegExpSubstitute=1
substitute = "#CRLF#":""
CodePage=949

[AA0003]
Measure=Plugin
Plugin=Plugins\WebParser.dll
Url=#MyFile#
RegExp=(?siU)](.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)
StringIndex=3
RegExpSubstitute=1
substitute = "#CRLF#":""
CodePage=949

[AA0004]
Measure=Plugin
Plugin=Plugins\WebParser.dll
Url=#MyFile#
RegExp=(?siU)](.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*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)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)
StringIndex=5
RegExpSubstitute=1
substitute = "#CRLF#":""
CodePage=949

[AA0012]
Measure=Plugin
Plugin=Plugins\WebParser.dll
Url=#MyFile#
RegExp=(?siU)](.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)
StringIndex=12
RegExpSubstitute=1
substitute = "#CRLF#":""
CodePage=949

[AA0013]
Measure=Plugin
Plugin=Plugins\WebParser.dll
Url=#MyFile#
RegExp=(?siU)](.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)
StringIndex=13
RegExpSubstitute=1
substitute = "#CRLF#":""
CodePage=949



-[Output]------------------------------------------------------------------------------------------------------------

[Output1]
meter=String
MeasureName=AA0001
DynamicVariables = 1 
Text=%1
X=0
Y=100
UpdateDivider = 1
AntiAlias=1


[Output2]
meter=String
MeasureName=AA0002
DynamicVariables = 1 
Text=%1
X=0R
Y=0r
UpdateDivider = 1
AntiAlias=1
LeftMouseUpAction=[!CommandMeasure "OutPutR2" "ExecuteBatch 1"][!RainmeterRedraw]

[Output3]
meter=String
MeasureName=AA0003
DynamicVariables = 1 
Text=%1
X=0R
Y=0r
UpdateDivider = 1
AntiAlias=1
LeftMouseUpAction=[!CommandMeasure "OutPutR3" "ExecuteBatch 1"][!RainmeterRedraw]

[Output4]
meter=String
MeasureName=AA0004
DynamicVariables = 1 
Text=%1
X=0R
Y=0r
UpdateDivider = 1
AntiAlias=1
LeftMouseUpAction=[!CommandMeasure "OutPutR4" "ExecuteBatch 1"][!RainmeterRedraw]

[Output5]
meter=String
MeasureName=AA0005
DynamicVariables = 1 
Text=%1
X=0R
Y=0r
UpdateDivider = 1
AntiAlias=1
LeftMouseUpAction=[!CommandMeasure "OutPutR5" "ExecuteBatch 1"][!RainmeterRedraw]

...

[Output12]
meter=String
MeasureName=AA0012
DynamicVariables = 1
Text=%1
X=0
Y=25r
UpdateDivider = 1
AntiAlias=1
LeftMouseUpAction=[!CommandMeasure "OutPutR12" "ExecuteBatch 1"][!RainmeterRedraw]

[Output13]
meter=String
MeasureName=AA0013
DynamicVariables = 1
Text=%1
X=0R
Y=0r
UpdateDivider = 1
AntiAlias=1
LeftMouseUpAction=[!CommandMeasure "OutPutR13" "ExecuteBatch 1"][!RainmeterRedraw]


-[OutPutR]-------------------------------------------------------------------------------------------------------------

[OutPutR1]
Measure=Plugin
Plugin=InputText
DefaultValue=1
Command1=[!WriteKeyValue Variables LogNum [CLC_NumPlus]][!SetVariable LogNum [CLC_NumPlus]][!WriteKeyValue Variables [CLC_Num3] "[AA0001]" "#@#VOCA.inc"][!WriteKeyValue 3T Text "#*[CLC_Num1]*#"][!WriteKeyValue 2T Text "#*[CLC_Num2]*#"][!WriteKeyValue 1T Text "#*[CLC_Num3]*#"][!Redraw][!Refresh]
DynamicVariables=1


[OutPutR2]
Measure=Plugin
Plugin=InputText
DefaultValue=1
Command1=[!WriteKeyValue Variables LogNum [CLC_NumPlus]][!SetVariable LogNum [CLC_NumPlus]][!WriteKeyValue Variables [CLC_Num3] "[AA0002]" "#@#VOCA.inc"][!WriteKeyValue 3T Text "#*[CLC_Num1]*#"][!WriteKeyValue 2T Text "#*[CLC_Num2]*#"][!WriteKeyValue 1T Text "#*[CLC_Num3]*#"][!Redraw][!Refresh]
DynamicVariables=1


[OutPutR3]
Measure=Plugin
Plugin=InputText
DefaultValue=1
Command1=[!WriteKeyValue Variables LogNum [CLC_NumPlus]][!SetVariable LogNum [CLC_NumPlus]][!WriteKeyValue Variables [CLC_Num3] "[AA0003]" "#@#VOCA.inc"][!WriteKeyValue 3T Text "#*[CLC_Num1]*#"][!WriteKeyValue 2T Text "#*[CLC_Num2]*#"][!WriteKeyValue 1T Text "#*[CLC_Num3]*#"][!Redraw][!Refresh]
DynamicVariables=1



-[InputPrograming]-------------------------------------------------------

[CLC_Num1]
Measure=Calc
Formula=(#LogNum#-2)
DynamicVariables=1

[CLC_Num2]
Measure=Calc
Formula=(#LogNum#-1)
DynamicVariables=1

[CLC_Num3]
Measure=Calc
Formula=(#LogNum#)
DynamicVariables=1


[CLC_NumPlus]
Measure=Calc
Formula=(#LogNum#+1)
IfEqualValue=#LogMax#
IfEqualAction=[!WriteKeyValue Variables LogNum 1][!SetVariable LogNum 0][!WriteKeyValue 3T Text "#*-2*#"][!WriteKeyValue 2T Text "#*-1*#"][!WriteKeyValue 1T Text "#*0*#"][!Refresh]
DynamicVariables=1

[1T]
Meter=String
Text=#0#
hidden=1

[2T]
Meter=String
Text=#-1#
hidden=1

[3T]
Meter=String
Text=#-2#
hidden=1



-[Tilte]-------------------------------------------------------------------------------------------------


[Title]
Meter=String
FontSize=18
FontStyle=bold
Text=word arranging
ClipString=1
AntiAlias=1
X=-5
Y=50

[Line]
Meter=String
SolidColor=255,255,255
W=550
H=2
X=0
Y=85

[RefreshButton]
Meter=String
SolidColor=255,255,255,100
x=370
Y=50
W=30
H=30
LeftMouseUpAction=[!Refresh]
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: I want to reduce the number of codes and meters.

Post by balala »

gkmaz9 wrote: December 5th, 2019, 5:57 am example1. I want to reduce the repeated code.(I want 100 StringIndex)

Code: Select all

RegExp=(?siU)](.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\.....
example2. I want to reduce the number of repeating meters.

Code: Select all

[AA0001]
Measure=Plugin
Plugin=Plugins\WebParser.dll
~
[AA0100]
Measure=Plugin
Plugin=Plugins\WebParser.dll

example3. I want to reduce the number of repeating meters.
However, the number inside the meter also increases by one.

Code: Select all

[Output1]
meter=String
MeasureName=AA0001
DynamicVariables = 1 
LeftMouseUpAction=[!CommandMeasure "OutPutR1" "ExecuteBatch 1"][!RainmeterRedraw]
~
[Output100]
meter=String
MeasureName=AA0100
DynamicVariables = 1 
LeftMouseUpAction=[!CommandMeasure "OutPutR100" "ExecuteBatch 1"][!RainmeterRedraw]
No way to reduce the number of repeats in this case. You have to explicitely add all (.*) symbols, all measures and all meters, in order to get them working. No way to skip any of these.
But:

gkmaz9 wrote: December 5th, 2019, 5:57 am Summary version of the actual skin for how it works
However you can reduce the length of the code if you're using the WebParser measure in a correct manner. These measures should have a parnet - child structure, one measure should be the parent measure, all others should be child measures. In your code all WebParser measures are working as parent measures, all of them having set URL, RegExp and so on options, which are not needed. For instance [AA0001] should be the parent measure and all others should be related to this one:

Code: Select all

[AA0001]
Measure=WebParser
Url=#MyFile#
RegExp=(?siU)](.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)\ (.*)
StringIndex=1
RegExpSubstitute=1
substitute = "#CRLF#":""
CodePage=949

[AA0002]
Measure=WebParser
Url=[AA0001]
StringIndex=2
RegExpSubstitute=1
substitute = "#CRLF#":""
CodePage=949

[AA0003]
Measure=WebParser
Url=[AA0001]
StringIndex=3
RegExpSubstitute=1
substitute = "#CRLF#":""
CodePage=949

[AA0004]
Measure=WebParser
Url=[AA0001]
StringIndex=4
RegExpSubstitute=1
substitute = "#CRLF#":""
CodePage=949

[AA0005]
Measure=WebParser
Url=[AA0001]
StringIndex=5
RegExpSubstitute=1
substitute = "#CRLF#":""
CodePage=949

[AA0012]
Measure=WebParser
Url=[AA0001]
StringIndex=12
RegExpSubstitute=1
substitute = "#CRLF#":""
CodePage=949

[AA0013]
Measure=WebParser
Url=[AA0001]
StringIndex=13
RegExpSubstitute=1
substitute = "#CRLF#":""
CodePage=949
Also note that although once WebParser was a plugin, in meantime it became an internal measure, so I replaced the Measure=Plugin and Plugin=Plugins\WebParser.dll options with Measure=WebParser.

And one more: on codes using WebParser measures, the Update should be set always to the default Update=1000, not Update=100. Here you can read why.
User avatar
Yamajac
Posts: 134
Joined: June 30th, 2014, 8:44 am

Re: I want to reduce the number of codes and meters.

Post by Yamajac »

Code: Select all

[Rainmeter]
Update = -1

[GrabString]
Measure  = WebParser
URL      = file://#CURRENTPATH#tester.rs
RegExp   = (?s)(.*)
UpdateDivider  = 5
UpdateRate     = 1
FinishAction   = [!UpdateMeasureGroup HowMany][!UpdateMeterGroup ShowIt][!Redraw]
[MakeTheZeroes]
Measure = String
String = [GrabString]
Group = HowMany
DynamicVariables = 1
RegExpSubstitute = 1
Substitute = "[^\r]" : "", "\r" : "0", "(.*)" : "1\1"
[CountTheZeroes]
Measure = Calc
Formula = log([MakeTheZeroes]) + 1
DynamicVariables = 1
Group = HowMany

[GetTheLine]
Measure = String
DynamicVariables = 1
Group = HowMany
MinValue = [GetMouseY]
String = [GrabString]
RegExpSubstitute = 1
Substitute = "(?s)([^\n]*?\n){0,[GetTheLine:MinValue]}([^\n]*?)(\n|$).*" : "\2", "[\r\n]" : ""

[GetMouseY]
Measure  = Calc
Formula  = (Ceil(#MouseY#) - 1) = -1 ? 0 : (Ceil(#MouseY#) - 1)
DynamicVariables = 1

[f---]
meter = string
Group = ShowIt
DynamicVariables = 1
SolidColor = 0,0,0,1
Text = [GrabString]
LeftMouseUpAction = [!SetVariable MouseY "($MouseY$ / ([f---:h] / [CountTheZeroes]))"][!UpdateMeasure GetMouseY][!UpdateMeasure GetTheLine][!WriteKeyValue variables tester "[GetTheLine]" tester.inc]

Take the entire file in the webparser measure and draw it WITH the #CRLF# characters in a single string measure. The #CRLF# characters will put each line on a new line in the string meter. This reduces the number of webparser measures to one, and the number of meters to display the lines to one.

Then we calculate the number of lines in the file with some simple math. This solution will work up to like 309? lines. I have a solution that will work for up to 500 here if you need that many lines.

And finally, when you click on the string meter, we take the y value of the mouse, divide it by the lineheight (the height of the meter divided by the number of lines) to get which line was clicked on. Pass that value to a calc measure to make it a nice round number for our string measure's regex. And then we update the [GetTheLine] measure which grabs the nth line in the file, where n is the line in the meter that was clicked on. And finally, we write the value of this measure to a file.


That all make sense?
gkmaz9
Posts: 67
Joined: August 26th, 2019, 10:42 am

Re: I want to reduce the number of codes and meters.

Post by gkmaz9 »

Yamajac wrote: December 5th, 2019, 8:10 am
That all make sense?
Since I am learning English, the transmission of meaning may be inaccurate.

----------------------------------

Thank you for answer. I have looked very carefully for a long time.

but I'm still a novice, I didn't understand the code exactly.
I am very weak at regular expressions.

I don't know how it works through formulas.
I just Tested one by one. I guess a main intention.

1.Extract the clicked line of the text file containing the text.
2.Write the obtained lines on another text file.

Is this your intention?

-----------------------------------

I want to get word by word
However, I was impressed by the way that extract a line of text through a short meters.

----------------------------------

And I want to ask you some questions I don't know.

For,example

1. Substitute = "[^\r]" : "", "\r" : "0", "(.*)" : "1\1"

I do not know what this means.
I know the meaning of each sign, but I don't know what it is for.
Can you tell me the simple intention of that part?

(?s)(.*) : All text
^ : Beginning of article
(.*) : Word I want to find
\r : beginning of line
\n : end of line
\1 : get the first one checked
$: End of article
| : I don't know this.


2. Substitute = "(?s)([^\n]*?\n){0,[GetTheLine:MinValue]}([^\n]*?)(\n|$).*" : "\2", "[\r\n]" : ""
I don't know this at all. Interpretation is needed.

3. Formula = (Ceil(#MouseY#) - 1) = -1 ? 0 : (Ceil(#MouseY#) - 1)
I don't understand the conditional statement.
What is Ceil (# MouseY #)?
gkmaz9
Posts: 67
Joined: August 26th, 2019, 10:42 am

Re: I want to reduce the number of codes and meters.

Post by gkmaz9 »

balala wrote: December 5th, 2019, 7:56 am No way to reduce the number of repeats in this case. You have to explicitely add all (.*) symbols, all measures and all meters, in order to get them working. No way to skip any of these.
Thank you for always good advice

I am a bit disappointed that there is no suitable way.
When I work, there are a lot of repeating meters, so the writing becomes very long. I want the associated plugin to be developed.
some of My skins have over 200,000 characters. Due to repeating meters :-(

There is no special relationship between the meters because the words are listed one by one in long texts such as novels, not web documents.
The purpose of this skin is to quickly read unknown words while reading in English.

Code: Select all

Measure=WebParser
This part is very helpful.
Hundreds of the same, I find it easy to write a line.

I read the link you gave me
I didn't have a big problem using the Update part, but I will keep 1000 if there is no specific reason.
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: I want to reduce the number of codes and meters.

Post by balala »

gkmaz9 wrote: December 5th, 2019, 11:00 am I didn't have a big problem using the Update part, but I will keep 1000 if there is no specific reason.
When you're reading a local file, there is no problem indeed. But if you're going outside to internet using a WebParser measure and you parse online information, well, in this case there might be a problem. If you set the Update to 100, the skin is updated ten times per second, opposed to the "normal" (default) one update per second. If you don't set an UpdateRate on the parent WebParser measure, it uses the default UpdateRate=600, which if the Update has the default Update=1000 value means one update per 10 minutes, but with Update=100, it means one update per minute, which in some cases can be too much.
The general advice is to set the default Update=1000 on all skins using WebParser measures. This is the most comfortable value, which in most cases doesn't create problems.
For details read the last paragraph of the What about UpdateRate? section of this description.
gkmaz9
Posts: 67
Joined: August 26th, 2019, 10:42 am

Re: I want to reduce the number of codes and meters.

Post by gkmaz9 »

balala wrote: December 5th, 2019, 3:34 pm When you're reading a local file, there is no problem indeed. But if you're going outside to internet using a WebParser measure and you parse online information, well, in this case there might be a problem. If you set the Update to 100, the skin is updated ten times per second, opposed to the "normal" (default) one update per second. If you don't set an UpdateRate on the parent WebParser measure, it uses the default UpdateRate=600, which if the Update has the default Update=1000 value means one update per 10 minutes, but with Update=100, it means one update per minute, which in some cases can be too much.
The general advice is to set the default Update=1000 on all skins using WebParser measures. This is the most comfortable value, which in most cases doesn't create problems.
For details read the last paragraph of the What about UpdateRate? section of this description.
I didn't know exactly why not to use 'Update = 100'. Because it had always worked.
but Thanks to the easy explanation, I've definitely learned why not to use.
Thank you for your kind explanation.
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: I want to reduce the number of codes and meters.

Post by balala »

gkmaz9 wrote: December 5th, 2019, 3:56 pm I didn't know exactly why not to use 'Update = 100'. Because it had always worked.
but Thanks to the easy explanation, I've definitely learned why not to use.
Thank you for your kind explanation.
It definitely does work, not this is the problem.
The problem is what have I described above. Using the Update=100 and not the according UpdateRate, can lead you to be banned as user of the site you're parsing (as described).
And I'm glad if I explained in a way that you understood. :thumbup:
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: I want to reduce the number of codes and meters.

Post by balala »

gkmaz9 could you please post an example of how does look the file you're parsing with your skin?
User avatar
Yamajac
Posts: 134
Joined: June 30th, 2014, 8:44 am

Re: I want to reduce the number of codes and meters.

Post by Yamajac »

gkmaz9 wrote: December 5th, 2019, 10:48 am 1. Substitute = "[^\r]" : "", "\r" : "0", "(.*)" : "1\1"

I do not know what this means.
I know the meaning of each sign, but I don't know what it is for.
Can you tell me the simple intention of that part?

(?s)(.*) : All text
^ : Beginning of article
(.*) : Word I want to find
\r : beginning of line
\n : end of line
\1 : get the first one checked
$: End of article
| : I don't know this.
Not quite. In fact, you didn't get pretty much any of that right.


"[^\r]" : "" replaces every character that ISN'T \r (carriage return) with an empty string. This leaves us with a string that is just a list of carriage returns for each line. So if there's 7 lines, we have 6 carriage returns - since the last line won't have a carriage return. We then replace all of the carriage returns with 0, and add a 1 to the front of the string. Then we pass the number to a calc measure to do a log() which will return 1 less than the number of lines (since the final line didn't have a carriage return). We can then use this number for some calculations elsewhere.
gkmaz9 wrote: December 5th, 2019, 10:48 am 2. Substitute = "(?s)([^\n]*?\n){0,[GetTheLine:MinValue]}([^\n]*?)(\n|$).*" : "\2", "[\r\n]" : ""
I don't know this at all. Interpretation is needed.
(?s) is telling the regex that dot matches newline characters - \r and \n.

Then we grab the first N lines, where N is GetTheLine:MinValue with ([^\n]*?\n){0,[GetTheLine:MinValue]}.

This grabs every character that ISN'T a newline character [^\n] until it reaches a newline character. Then it repeats that N times where N is GetTheLine:MinValue with {0,[GetTheLine:MinValue]} which tells the regex to repeat between 0 times and N times. Rainmeter resolves the variable before the regex is processed.

Afterwards, we use ([^\n]*?)(\n|$) to grab everything before the newline or end of string. Then we use .* to consume everything afterwards so we can replace the string with JUST the line that we grabbed.

And the final regex just removes all of the carriage returns/newlines from the string so we're left with a nice one line string since the previous regex grabs the carriage return. I could fix that, but I didn't :D
gkmaz9 wrote: December 5th, 2019, 10:48 am 3. Formula = (Ceil(#MouseY#) - 1) = -1 ? 0 : (Ceil(#MouseY#) - 1)
I don't understand the conditional statement.
What is Ceil (# MouseY #)?
x ? true : false

(RoundUp(#MouseY# - 1)) = -1 ? 0 : (RoundUp(#MouseY# - 1))

This just checks if MouseY is less than 0 since if you click at the very very top pixel of the meter, you'll have exactly 0 which will end up being -1 after we subtract 1 from it in the string meter LeftMouseUpAction. Anything above 0 will get rounded up to 0 anyway, but that pixel perfect click can still happen.


As you can see, this will display all the lines in a file, and whichever one you click on gets written to a different file.


Also, you shouldn't view Update=1000 as normal, you should use whatever update rate you need for your skin. Sometimes that's less than 1000, sometimes it's more. Use whatever you need, but be aware of what measures you're using and what impact they have on performance.


Make sense now?