It is currently April 28th, 2024, 4:42 pm

Mish-Mash Write contents of a measure to TXT file [solved]

Get help with creating, editing & fixing problems with skins
User avatar
CodeCode
Posts: 1366
Joined: September 7th, 2020, 2:24 pm
Location: QLD, Australia

Mish-Mash Write contents of a measure to TXT file [solved]

Post by CodeCode »

I have been looking for various examples, but they all do not really match my goal.

The idea is for the value of a measure to be written to a text file.

I'm lost,

Here is the skin:
Sleep Diary_1.0.rmskin
I apologise for the possibility that this mish mash is completely wrong. Focusing on the write to file. (everything else works great - until now).
I am not getting any results. So, what I mean by mish mash, is I have been trying to cross associate other peoples code snippets, into this.

Thanks for any help

The relevant parts are mostly at the end of the Awake.ini
You do not have the required permissions to view the files attached to this post.
Last edited by CodeCode on December 26th, 2023, 3:23 am, edited 1 time in total.
ƈǟռ'ȶ ʄɨӼ ɨȶ ɨʄ ɨȶ ǟɨռ'ȶ ɮʀօӄɛ - ʊռʟɛֆֆ ɨȶ ɨֆ ɨռ ƈօɖɛ.
User avatar
balala
Rainmeter Sage
Posts: 16184
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Mish-Mash Write contents of a measure to TXT file

Post by balala »

CodeCode wrote: December 25th, 2023, 6:49 pm The idea is for the value of a measure to be written to a text file.
Which option of which section is the one which should write the value of a measure (most probably as a variable) into the file and doesn't do? Because there are lot of bangs which are writing values of different variables as variables and those bangs are writing the appropriate values correctly to the file (however I obviously haven't even checked them all, but the two I did, wrote the values correctly). But didn't find the bang you have problems with.
So, which is the problematic bang? In which option of which section is it placed?
User avatar
CodeCode
Posts: 1366
Joined: September 7th, 2020, 2:24 pm
Location: QLD, Australia

Re: Mish-Mash Write contents of a measure to TXT file

Post by CodeCode »

It worked for you? Would you mind pasting the lines from the SleepDiary.txt file, please?

I click the Log button, but nothing happens. The SleepDiary.txt remains empty.

These are the only measures that I would deem relevant:

Code: Select all

[MeasureLogTime]
Measure=Time
Format=%A %d.%m.%Y- %H:%M:%S

[MeasureInput]
Measure=Plugin
Plugin=RunCommand
Program=Powershell
State=Hide
OutputType=ANSI
OutputFile=#@#SleepDiary.txt
Command1=[!CommandMeasure MeasureLua "AddToLine([AverageResult])"][!Refresh]
DynamicVariables=1

[MeterLogClick]
Meter=String
SolidColor=0,0,0,1
X=297
Y=480
FontFace=#TallFont#
FontColor=#OuterEdge#
StringAlign=CenterCenter
FontWeight=700
InlineSetting=CharacterSpacing | 1 | 1
FontSize=10
Text=LOG
LeftMouseUpAction=[!CommandMeasure MeasureInput "Run"]
DynamicVariables=1
ƈǟռ'ȶ ʄɨӼ ɨȶ ɨʄ ɨȶ ǟɨռ'ȶ ɮʀօӄɛ - ʊռʟɛֆֆ ɨȶ ɨֆ ɨռ ƈօɖɛ.
User avatar
CodeCode
Posts: 1366
Joined: September 7th, 2020, 2:24 pm
Location: QLD, Australia

Re: Mish-Mash Write contents of a measure to TXT file

Post by CodeCode »

I think there is a much simpler solution.
I saw something that posited the idea of simply using the !WriteKeyValue bang.

It does work, but the idea is that each time the 'Log' button is clicked, a new line would be written.

I am not sure how, if possible, to make the Variable advance. Like LogTime1= LogTime2=, each time a new line would be generated with #CRLF# and the new variable name.

But since I have been writing this post, it occurred to me to make the variable advance using another variable with the LogTime#var#= , then advance the #var# variable every time the log button is clicked.

This is going to be much simpler than recycling an old lua file that is meant to work with a completely unnecessary $inputtext$.

I will try that, and post about that effort here.
ƈǟռ'ȶ ʄɨӼ ɨȶ ɨʄ ɨȶ ǟɨռ'ȶ ɮʀօӄɛ - ʊռʟɛֆֆ ɨȶ ɨֆ ɨռ ƈօɖɛ.
User avatar
CodeCode
Posts: 1366
Joined: September 7th, 2020, 2:24 pm
Location: QLD, Australia

Re: Mish-Mash Write contents of a measure to TXT file

Post by CodeCode »

Okey Dokey.

I have what seems to be an excellent result with the !WriteKeyVariable Bang.

This is the line of code I used:

Code: Select all

Text=LOG
LeftMouseUpAction=[!SetVariable var "(#var#+1)"][!WriteKeyValue Variables var "[#var]" "#@#_Awake.inc"][!WriteKeyValue Variables LogEntry#var# "LogTime:[MeasureLogTime] Average:[AverageResult]" "#@#SleepDiary.ini"][!Update]
So I 'think' that is it for now.

Thanks balala for taking time to look into this.
ƈǟռ'ȶ ʄɨӼ ɨȶ ɨʄ ɨȶ ǟɨռ'ȶ ɮʀօӄɛ - ʊռʟɛֆֆ ɨȶ ɨֆ ɨռ ƈօɖɛ.
User avatar
CodeCode
Posts: 1366
Joined: September 7th, 2020, 2:24 pm
Location: QLD, Australia

Re: Mish-Mash Write contents of a measure to TXT file

Post by CodeCode »

CodeCode wrote: December 26th, 2023, 3:23 am Okey Dokey.

I have what seems to be an excellent result with the !WriteKeyVariable Bang.

This is the line of code I used:

Code: Select all

Text=LOG
LeftMouseUpAction=[!SetVariable var "(#var#+1)"][!WriteKeyValue Variables var "[#var]" "#@#_Awake.inc"][!WriteKeyValue Variables LogEntry#var# "LogTime:[MeasureLogTime] Average:[AverageResult]" "#@#SleepDiary.ini"][!Update]
So I 'think' that is it for now.

Thanks balala for taking time to look into this.
SideNote: The Sleep Diary entries are being sent to an .ini. This was explained in that old post as the only way this idea could work. NB: It was so old - the post - that I think !WriteKeyvalue bang was in a Beta. :thumbup:
ƈǟռ'ȶ ʄɨӼ ɨȶ ɨʄ ɨȶ ǟɨռ'ȶ ɮʀօӄɛ - ʊռʟɛֆֆ ɨȶ ɨֆ ɨռ ƈօɖɛ.
User avatar
Yincognito
Rainmeter Sage
Posts: 7179
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Mish-Mash Write contents of a measure to TXT file

Post by Yincognito »

CodeCode wrote: December 26th, 2023, 3:23 am Okey Dokey.

I have what seems to be an excellent result with the !WriteKeyVariable Bang.

This is the line of code I used:

Code: Select all

Text=LOG
LeftMouseUpAction=[!SetVariable var "(#var#+1)"][!WriteKeyValue Variables var "[#var]" "#@#_Awake.inc"][!WriteKeyValue Variables LogEntry#var# "LogTime:[MeasureLogTime] Average:[AverageResult]" "#@#SleepDiary.ini"][!Update]
So I 'think' that is it for now.

Thanks balala for taking time to look into this.
I guess at some point you might want to "recycle and reuse" the log so that way too old entries are being rewritten with new ones. You already store the line where you write, which is good, the only thing you'd need to do if you want such an ability is to set var to either the value you're setting, or set it back to 1 or similar if its current value is past some threshold. I'm using roughly the same technique to "log" the already read feed items in the Feeds skin from my suite.
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
User avatar
balala
Rainmeter Sage
Posts: 16184
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Mish-Mash Write contents of a measure to TXT file

Post by balala »

CodeCode wrote: December 26th, 2023, 12:50 am It worked for you? Would you mind pasting the lines from the SleepDiary.txt file, please?

I click the Log button, but nothing happens. The SleepDiary.txt remains empty.
The SleepDiary.txt file remains empty. But you didn't describe in your first post what do you expect to happen:
CodeCode wrote: December 25th, 2023, 6:49 pm The idea is for the value of a measure to be written to a text file.
So, I looked for a bang which should write a value returned by a measure. Didn1t find such a bang, so posted my reply.
You definitely should be much more precise when you post a question. You should explain what we have to do and in what circumstances what should be written is not written. Sorry but no one out there can't figure these out.
User avatar
CodeCode
Posts: 1366
Joined: September 7th, 2020, 2:24 pm
Location: QLD, Australia

Re: Mish-Mash Write contents of a measure to TXT file

Post by CodeCode »

balala wrote: December 26th, 2023, 6:59 am The SleepDiary.txt file remains empty. But you didn't describe in your first post what do you expect to happen:

So, I looked for a bang which should write a value returned by a measure. Didn1t find such a bang, so posted my reply.
You definitely should be much more precise when you post a question. You should explain what we have to do and in what circumstances what should be written is not written. Sorry but no one out there can't figure these out.
Sorry if I was ambiguous about my issue. It seemed to me like I described it ok, I guess not.

I found a solution, in the by and by, so I am happy about that.
Yincognito wrote: December 26th, 2023, 5:30 am I guess at some point you might want to "recycle and reuse" the log so that way too old entries are being rewritten with new ones. You already store the line where you write, which is good, the only thing you'd need to do if you want such an ability is to set var to either the value you're setting, or set it back to 1 or similar if its current value is past some threshold. I'm using roughly the same technique to "log" the already read feed items in the Feeds skin from my suite.
I am just using RunCommand to start a new log file that overwrites the old one, like you say; the need will likely arise eventually, So I built in a create new log on LeftMouseUpAction on a different meter. I had something already that was pretty straight forward, just changed it to suit my current need.
The File is created with the first default line of [Variables]. It seemed logical to do that so the !WriteKeyValue would see the log entries as variables and not just text, also since the idea was that the !WriteKeyValue bang will only work on an ini or inc file.
There is also a place to click and open the log ini. I am not worried that the ini would pose a problem since every text editor in the world can open an ini. :p
ƈǟռ'ȶ ʄɨӼ ɨȶ ɨʄ ɨȶ ǟɨռ'ȶ ɮʀօӄɛ - ʊռʟɛֆֆ ɨȶ ɨֆ ɨռ ƈօɖɛ.
User avatar
balala
Rainmeter Sage
Posts: 16184
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Mish-Mash Write contents of a measure to TXT file

Post by balala »

CodeCode wrote: December 26th, 2023, 12:12 pm I found a solution, in the by and by, so I am happy about that.
:thumbup: