It is currently May 27th, 2024, 12:07 am

Read a text file into a meter?

Get help with creating, editing & fixing problems with skins
PhYoshi
Posts: 2
Joined: February 18th, 2011, 7:17 pm

Read a text file into a meter?

Post by PhYoshi »

In effect, I have a text file, and I want it on my desktop. My chosen weapon is rainmeter - how can I load this text file and display it, retaining line breaks and tabs and so such?
User avatar
jsmorley
Developer
Posts: 22634
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Read a text file into a meter?

Post by jsmorley »

Here you go...

This requires the latest Rainmeter 3.0 beta (or later) from http://rainmeter.net.
LuaTextFile_2.0.rmskin
LuaTextFile.jpg
I used tabs in the test .txt file, and then had Lua turn them into 5 space on the way out as Rainmeter is not that crazy about tabs in meters. You can easily change that to any number of spaces in the string.gsub() statement in the .lua. I threw in a blank line to be sure that would work ok.

Sample text file:

Code: Select all

09 AM:	Go to bank and finish paperwork.

10 AM:	Attend medical appointment.
12 PM:	Eat lunch.
01 PM:	Shop for household necessities.
03 PM:	Shop for food.
05 PM:	Prepare dinner for family.
06 PM:	Eat dinner with family.
07 PM:	Do some cleaning.
08 PM:	Оплатить счет за электричество.
09 PM:	Relaxation time.
You do not have the required permissions to view the files attached to this post.
User avatar
jsmorley
Developer
Posts: 22634
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Read a text file into a meter?

Post by jsmorley »

I didn't put it in, but you might want to add:

UpdateDivider=xx

To the Script measure, with "xx" being the number of seconds between checking the text file. You probably don't want to leave it off, as it will check every 1 second, which is probably going to have it working harder than it needs to. I would set it to 5 or 10 or something. You want it to be responsive to changes to the text file, but not ridiculous about it.
User avatar
jsmorley
Developer
Posts: 22634
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Read a text file into a meter?

Post by jsmorley »

:-)
2-18-2011 4-01-54 PM.png
You do not have the required permissions to view the files attached to this post.
PhYoshi
Posts: 2
Joined: February 18th, 2011, 7:17 pm

Re: Read a text file into a meter?

Post by PhYoshi »

Excellent, your help both here and through IRC was invaluable. Thanks muchly :)
User avatar
jsmorley
Developer
Posts: 22634
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Read a text file into a meter?

Post by jsmorley »

My pleasure. Nice chat.
pnikkosis
Posts: 4
Joined: August 10th, 2009, 9:45 pm

Re: Read a text file into a meter?

Post by pnikkosis »

Hey guys, I was trying to do the same thing as the thread creator, but I was wondering, the skin comes with an "update=1000" line; isn't that supose to be the delay between the reads to the file? should I still add "UpdateDivider=xx"?
In my tests that's what that line does, and it's in miliseconds right?

And another question, can I make the meter clickeable, so it opens the file in notepad?
User avatar
Chewtoy
Moderator
Posts: 995
Joined: June 10th, 2009, 12:44 pm
Location: Sweden

Re: Read a text file into a meter?

Post by Chewtoy »

Update=1000 is used in the [Rainmeter] section to tell rainmeter how often to update the skin.
While in measures you use UpdateDivider or UpdateRate (check the manual when to use what) you delay that specific measure from updating.
Update is in milliseconds, in UpdateDivider and UpdateRate that value is multiplied.
So it will be Update * UpdateRate, or Update * UpdateDivider.
If you don't want to read the textfile on every update, you can add a UpdateDivider to it if you like (add it to the script measure).

Add LeftMouseUpAction=!Execute ["#CurrentPath#Test.txt"]
on the meter.
I don't think, therefore I'm not.
LordRaiden
Posts: 1
Joined: February 22nd, 2012, 5:25 pm

Re: Read a text file into a meter?

Post by LordRaiden »

Is there any way I could display a text from a website? Example: http://upperboxnetcafe.webs.com/News.txt
User avatar
jsmorley
Developer
Posts: 22634
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Read a text file into a meter?

Post by jsmorley »

LordRaiden wrote:Is there any way I could display a text from a website? Example: http://upperboxnetcafe.webs.com/News.txt
http://rainmeter.net/cms/Tips-WebParserPrimer