11 Dec 21:11
Re: LSX Command > Add text to file
From: Jochen Ritzel <THC_rulez@...>
Subject: Re: LSX Command > Add text to file
Newsgroups: gmane.comp.windows.shells.litestep
Date: 2007-12-11 20:11:39 GMT
Subject: Re: LSX Command > Add text to file
Newsgroups: gmane.comp.windows.shells.litestep
Date: 2007-12-11 20:11:39 GMT
Try this:
1. Save that code to some file, ie $ThemeDir$tracker.lua
2. Edit that OUTFILE, you best use a absolute path like 'c:\\blah.txt' or
'c:/blah.txt' (windows does not care). If you use a relative path ( just
'blah.txt' ) it is relative to your LitestepDir.
2. Edit your theme.rc file
- add `*NetLoadModule lslua-0.6.5 load lslua`
- add `*Luafile "$ThemeDir$tracker.lua"`
3. Recycle
4. Run !Tracker client > text
That should do it.
Ah yeah, uncomment ( remove the -- ) before `lslua.message_box("An Error
occured: ".. msg, "Error!" ) and you'll see a more or less helpfull error
message if something goes wrong.
On Tue, 11 Dec 2007 20:45:00 +0100, Ace McKool <face7hill@...> wrote:
> Thanks for this! This is my first time with Lua, so I have a few
> follow-up
> questions:
>
> 1. Do I need any of the Lua packages to run this? e.g. textedit?
> 2. How do I confirm the path to the blah.txt file? I tried:
>
> OUTFILE = 'c:\\blah.txt"
>
> but that didn't seem to work. Thank you very much for this though, looks
> pretty cool.
>
>
>
>
> On Dec 11, 2007 6:32 AM, Jochen Ritzel <THC_rulez@...> wrote:
>
>> Some Lua:
>> [code, copy to some file and *luascriptfile it]
>> -- config this.
>> local clienttracker = {
>> OUTFILE = 'blah.txt',
>> -- if you want some formatting, you can set that here
>> INFORMAT = '%s*([^>]*) > (.*)%s*', -- the input string is parsed
>> with
>> this pattern
>> OUTFORMAT = '%s | %s', -- and formatted with this pattern
>> afterwards ... you could add tabs ( \t ) here ...
>> TIMESTAMP = true,
>> TIMEFORMAT = '%c', --see
>> http://www.thinkage.ca/english/gcos/expl/c/lib/strfti.html
>> ERROR = function(self, msg ) -- if an error occures, it is
>> reported with this function
>> lslua.message_box("An Error occured: ".. msg, "Error!" )
>> --print( "An Error occured:", msg )
>> end
>> }
>>
>> -- admire this.
>> function clienttracker:_format( client, text )
>> local s = self.OUTFORMAT:format( client, text)
>> if self.TIMESTAMP then
>> return ('%s: %s\n'):format( os.date( self.TIMEFORMAT), s )
>> else
>> return s
>> end
>> end
>> function clienttracker:parse( s )
>> local ok, client, text = pcall( string.match, s, self.INFORMAT )
>> if not ok then return self:ERROR( client ) end
>> ok, text = pcall( self.add, self, client, text )
>> if not ok then return self:ERROR( text ) end
>> end
>> function clienttracker:add( client, text )
>> local fp = io.open(self.OUTFILE, "a")
>> fp:write( self:_format( client, text ) )
>> fp:close()
>> end
>>
>> -- rename this.
>> function bang_tracker( s )
>> return clienttracker:parse( s )
>> end
>> [/code]
>>
>> Usage:
>> !tracker "You > I wrote you some code."
>>
>> Should be very easy to understand and expand ... hf
>>
>> --thc4k
>>
>>
>> On Mon, 10 Dec 2007 20:22:39 +0100, Ace McKool <face7hill@...>
>> wrote:
>>
>> > Hi Everyone,
>> >
>> > I'm trying to track my time at work. I was hoping to use LSXCommand
>> > (plus
>> > any needed modules) to do something like:
>> >
>> > ?tracker "Some Client > I did this for them"
>> >
>> > And it would simply write the string to a file and add a timestamp if
>> > possible.
>> >
>> > Anybody have any recommendations on how to get this started? Thanks!
>>
>>
>>
>> ---------------------------------------------------------------------
>> Can't Unsubscribe? Check http://desktopian.org/listunsub.html
>> LS List Homepage: http://wuzzle.org/list/litestep.php
>> Get the LS FAQ: http://lsfaq.shellfront.org
>>
>>
---------------------------------------------------------------------
Can't Unsubscribe? Check http://desktopian.org/listunsub.html
LS List Homepage: http://wuzzle.org/list/litestep.php
Get the LS FAQ: http://lsfaq.shellfront.org
RSS Feed