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

LuaTailFile - A skin to read logs, todo lists, etc.

Skins that control functions in Windows or Rainmeter
User avatar
Jkon
Posts: 185
Joined: December 4th, 2009, 2:05 am

Re: LuaTailFile - A skin to read logs, todo lists, etc.

Post by Jkon »

SKIN:Bang("!SetVariable LogVariable"..i.." "..tAllLines[iCount-i])

gives me No such config:is

playing with the ..amends continues to expect either an opening or closing bracket.I've tried quoting "tallLines" also as that will contain spaces also.

Seeing as dynamicvariables cant be used on a meter with settext forced on it,is it possible to force text on the variables within the variables section,thereby retaining the 2 table system you were already using.I've tried changing the code in the measure=script and "tMeters = tolua.cast(SKIN:GetMeter(sMeterPrefix..i), "CMeterString")" to point to the variables instead of the meters but (SKIN:Getvariable(sMeterPrefix..i), "CVariableString") wont work.
Image
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: LuaTailFile - A skin to read logs, todo lists, etc.

Post by jsmorley »

I'm not ignoring you, but am away from my computer until tomorrow afternoon. I'll figure out what you are seeing then, I'm sure it is some simple little thing.
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: LuaTailFile - A skin to read logs, todo lists, etc.

Post by jsmorley »

You want to toss up your skin and lua code so I can see what is going on?
User avatar
Jkon
Posts: 185
Joined: December 4th, 2009, 2:05 am

Re: LuaTailFile - A skin to read logs, todo lists, etc.

Post by Jkon »

In this one I've just added the variables and text = to your ini and made the meterstyle dynamic.Then replaced the settext line with your bang command.

Ini
[Variables]
LinesToRead=10
MeterPrefix="LogMeter"

LogVariable1=""
LogVariable2=""
LogVariable3=""
LogVariable4=""
LogVariable5=""
LogVariable6=""
LogVariable7=""
LogVariable8=""
LogVariable9=""
LogVariable10=""


[BackgroundStyle]
W=120
H=(20 * #LinesToRead# + 10)
SolidColor=3,43,87,150

[TextStyle]
X=5
Y=2R
FontFace=Trebuchet MS
FontSize=11
AntiAlias=1
StringStyle=Bold
DynamicVariables=1

[Color1Style]
FontColor=245,250,255,255

[Color2Style]
FontColor=255,250,232,255

[MeasureLuaScript]
Measure=Script
ScriptFile=#CURRENTPATH#LuaTailFile.lua
TableName=LuaTailFile
FileToRead="#CURRENTPATH#MyTextFile.txt"
LinesToRead=#LinesToRead#
MeterPrefix=#MeterPrefix#
UpdateDivider=5

[MeterBackground]
Meter=Image
MeterStyle=BackgroundStyle

[LogMeter1]
Meter=String
MeterStyle=TextStyle | Color1Style
Y=5
Text="#LogVariable1#"

[LogMeter2]
Meter=String
MeterStyle=TextStyle | Color2Style
Text="#LogVariable2#"

[LogMeter3]
Meter=String
MeterStyle=TextStyle | Color1Style
Text="#LogVariable3#"

[LogMeter4]
Meter=String
MeterStyle=TextStyle | Color2Style
Text="#LogVariable4#"

[LogMeter5]
Meter=String
MeterStyle=TextStyle | Color1Style
Text="#LogVariable5#"

[LogMeter6]
Meter=String
MeterStyle=TextStyle | Color2Style
Text="#LogVariable6#"

[LogMeter7]
Meter=String
MeterStyle=TextStyle | Color2Style
Text="#LogVariable7#"

[LogMeter8]
Meter=String
MeterStyle=TextStyle | Color1Style
Text="#LogVariable8#"

[LogMeter9]
Meter=String
MeterStyle=TextStyle | Color2Style
Text="#LogVariable9#"

[LogMeter10]
Meter=String
MeterStyle=TextStyle | Color1Style
Text="#LogVariable10#"
Lua
-- ## Information ################################################################
-- File: LuaTailFile.lua
-- Author: JSMorley
-- License: Creative Commons Attribution-Non-Commercial-Share Alike 3.0
-- Updated: December 22, 2010
-- ###############################################################################

-- ## Description ################################################################
-- Sample Lua script, demonstrating some ways to use the new integration of Lua
-- and Rainmeter. See LuaTailFile.ini for some tips on how to set up the skin.
--
-- Rainmeter, nor anyone associated with Rainmeter is responsible for teaching
-- you the Lua scripting langague. This sample is only meant to demonstrate
-- using the language with Rainmeter. There are many good sites where you can
-- learn Lua itself. I recommend it. It will open up a lot of possibilities.
-- ###############################################################################

-- ## Properties: ################################################################
-- This PROPERTIES table is required. It will be populated with the Key=Value
-- settings from the Measure=Script measure in your skin, below in the Initalize()
-- function. This is how you pass settings of your choice from the skin to the
-- Lua script. It can be empty, but must exist.
-- ###############################################################################
PROPERTIES =
{

FileToRead = "";
LinesToRead = 0;
MeterPrefix = "";

}

-- ## Initialize: ################################################################
-- The function Initialize() is used to set Lua to be able to read the values for
-- measures and meters from your skin later using GetValue(), and to define
-- and populate variables used in your script. This section is required.
--
-- In this case, I am setting variables for the Key=Value setting from the script
-- measure in the skin, then getting each meter starting with "MeterPrefix" and
-- putting the Rainmeter structure of the meter in a table/array called "tMeters".
-- With this name / structure I can later do things like "SetText" to the meters.
-- ###############################################################################
function Initialize()

sFileToRead = PROPERTIES.FileToRead
iLinesToRead = PROPERTIES.LinesToRead
sMeterPrefix = PROPERTIES.MeterPrefix

tMeters = {}
for i = 1, iLinesToRead do
tMeters = tolua.cast(SKIN:GetMeter(sMeterPrefix..i), "CMeterString")
end

end -- function Initialize

-- ## Update: ###################################################################
-- The function Update() is where you will put the bulk of your code. This code
-- is executed on every update of the skin, and is required. You can also add
-- your own functions in this file if needed, and call them from this function.
--
-- In this case I am opening the file defined in "FileToRead" in the skin, then
-- reading in the entire file into a table/array called "tAllLines". Then I
-- just iterate through that table, and using "SetText" for each meter in the
-- table "tMeters" set the meter to a line of text from the file, in reverse order.
-- ###############################################################################
function Update()

hReadingFile = io.input(sFileToRead)

tAllLines = {}
iCount = 1
while true do
local sLine = io.read()
if sLine == nil then break end
tAllLines[iCount] = sLine
iCount = iCount + 1
end

for i = 1, iLinesToRead do
SKIN:Bang("!SetVariable LogVariable"..i.." "..tAllLines[iCount-i])
end

io.flush(hReadingFile)

end -- function Update

-- ## GetStringValue: ############################################################
-- GetStringValue is a required function, which is how the script returns a value
-- to the calling Measure=Script in the skin. I'm not using this in this case,
-- so I just return the total lines read from the file.
-- ###############################################################################
function GetStringValue()
return tostring(iCount-1)
end -- function GetStringValue
Image
User avatar
Jkon
Posts: 185
Joined: December 4th, 2009, 2:05 am

Re: LuaTailFile - A skin to read logs, todo lists, etc.

Post by Jkon »

As that gives me Unknown Config:Is ,I'm presuming it's appending the "This line" in "This line is n" to the variable and then looking for a config to put the variable too.
Image
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: LuaTailFile - A skin to read logs, todo lists, etc.

Post by jsmorley »

The problem (again mine for not waiting til I was in a place where I could test things) is that the lines of text in the text file have spaces in them, and so unless you enclose the value you are sending when you do the !SetVariable bang, it splits it and assumes that part of it is the optional "Config" parameter for a !SetVariable bang.

SKIN:Bang("!SetVariable LogVariable"..i.." ".."\""..tAllLines[iCount-i].."\"")

Seems to fix it for me.

As you see, I am enclosing the tAllLines[iCount-i] in quotes. I have to "escape" the quotes with "\" so they are seen as a literal and actually sent as part of the bang, and not treated as delimiters in the function call itself.
User avatar
Jkon
Posts: 185
Joined: December 4th, 2009, 2:05 am

Re: LuaTailFile - A skin to read logs, todo lists, etc.

Post by Jkon »

I have to "escape" the quotes so they are actually sent as part of the bang and not treated as delimiters in the function call itself.
I could see what was going wrong but had no idea about how to escape the quotes.(should have considering how much of the manual i've read).Thanks for all your help.You may regret my starting to play with lua,there may be many,many,many more questions on the horizon. :D
Image
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: LuaTailFile - A skin to read logs, todo lists, etc.

Post by jsmorley »

Jkon wrote: I could see what was going wrong but had no idea about how to escape the quotes.(should have considering how much of the manual i've read).Thanks for all your help.You may regret my starting to play with lua,there may be many,many,many more questions on the horizon. :D
That's fine... I don't want to get into full blown Lua lessons here, but I'm glad to help where I can.
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: LuaTailFile - A skin to read logs, todo lists, etc.

Post by jsmorley »

I sent you a PM...
NisseDILLIGAF
Posts: 20
Joined: May 31st, 2011, 7:15 am

Re: LuaTailFile - A skin to read logs, todo lists, etc.

Post by NisseDILLIGAF »

Hi...

I really like this one!

I'm using it with mIRC ... the only thing is when there is a long row of text, It goes across my screen and sometimes beyond... :/

Is there anyway to do a line break when the line is more than X characters?

Thanx!