Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Writing a log file from an obey file

1 view
Skip to first unread message

Gavin Wraith

unread,
Feb 15, 2011, 10:17:00 AM2/15/11
to
In message <51a5dbfe09news*@Torrens.org.uk>
"Richard Torrens (News)" <News+...@Torrens.org.uk> wrote:

> Lua looks attractive, but it's a long learning curve for a single job!

Here is the single job then:

Write the following in a text file called "writelog":

do
local var,logfile,err = os.getenv,arg[1],"Cannot open "
local log = assert(io.open(logfile,"a+"),err..logfile)
log:write("\n",
var "Sys$Time"," on ",var "Sys$Date","\n",
var "cycle_No","\n",
var "file$","\n")
log:close()
end

Put it in the same directory as an Obey file containing

lua <Obey$Dir>.writelog <pathname_of_logfile>

Running the obeyfile will update your log file.

For learning Lua, Roberto Ierusalimschy's book "Programming in Lua"
(2-nd edition, ISBN 85-903798-2-5) is the authoritative text.
It is a good read for anybody interested in programming, whether in
Lua or not. It is the first edition which is online. For those who
have already begun, the "Lua 5.1 Reference Manual" (ISBN 85-903798-3-3)
is a useful adjunct (and very slim).

--
Gavin Wraith (ga...@wra1th.plus.com)
Home page: http://www.wra1th.plus.com/

Ron

unread,
Feb 16, 2011, 12:57:04 AM2/16/11
to
In message <8f26fda5...@wra1th.plus.com>
Gavin Wraith <ga...@wra1th.plus.com> wrote:

>
> For learning Lua, Roberto Ierusalimschy's book "Programming in Lua"
> (2-nd edition, ISBN 85-903798-2-5) is the authoritative text.
> It is a good read for anybody interested in programming, whether in
> Lua or not. It is the first edition which is online. For those who
> have already begun, the "Lua 5.1 Reference Manual" (ISBN 85-903798-3-3)
> is a useful adjunct (and very slim).
>

Thanks for the tip, I managed to download the 2nd edition as a PDF,
so I'll be able to print it out double-sided.
I'll now try for the 5/2 manual as a PDF
I have your HTML doc, do you perhaps have a printer friendly version?

TIA
Ron M.

Richard Torrens (News)

unread,
Feb 16, 2011, 4:20:45 AM2/16/11
to
In article <8f26fda5...@wra1th.plus.com>,

Gavin Wraith <ga...@wra1th.plus.com> wrote:
> In message <51a5dbfe09news*@Torrens.org.uk>
> "Richard Torrens (News)" <News+...@Torrens.org.uk> wrote:

> > Lua looks attractive, but it's a long learning curve for a single job!

> Here is the single job then:

> Write the following in a text file called "writelog":

> do
> local var,logfile,err = os.getenv,arg[1],"Cannot open "
> local log = assert(io.open(logfile,"a+"),err..logfile)
> log:write("\n",
> var "Sys$Time"," on ",var "Sys$Date","\n",
> var "cycle_No","\n",
> var "file$","\n")
> log:close()
> end

> Put it in the same directory as an Obey file containing

> lua <Obey$Dir>.writelog <pathname_of_logfile>

> Running the obeyfile will update your log file.

Brilliant! Will try that... Thanks

I spent an amount on Perl books, and find I don't need to do enough Perl
to remenmber it: at 67 I'm old enough that my forgetting curve is steeper
than my learning curve.

I wonder if Lua could be different: that it's so compact means it's a
great addition to RISC OS, especially with its interfacewith StrongED.

--
------------------------------------------------------------------
Richard Torrens. News email address is valid - for a limited time only.
http://www.Torrens.org.uk for genealogy, natural history, wild food, walks, cats
and more!

Gavin Wraith

unread,
Feb 16, 2011, 10:45:20 AM2/16/11
to
In message <51a6605ebbnews*@Torrens.org.uk>

"Richard Torrens (News)" <News+...@Torrens.org.uk> wrote:

> I spent an amount on Perl books, and find I don't need to do enough Perl
> to remenmber it: at 67 I'm old enough that my forgetting curve is steeper
> than my learning curve.

You have my sympathies. I too bought a book on Perl, but it did not
encourage me to use it. I am six weeks away from 72 and I am no
longer capable of wrestling with syntactic alligators. I see from
the TIOBE site, at
http://www.tiobe.com/content/paperinfo/tpci/ ,
that Perl's popularity has been in long term decline, probably
because there are easier beasts to tame.

> I wonder if Lua could be different: that it's so compact means it's a
> great addition to RISC OS, especially with its interfacewith StrongED.

That is certainly my belief. Have you seen this event, coming next
Monday:
http://www.rougol.jellybaby.net/meetings/index.html ?

Actually I think there are two reasons why Lua is particularly
appropriate for RISC OS. One is its compactness. The other is that
because it was originally developed for a state institution, PetroBras,
that was not swimming with money, it had to be made compatible with
the heterogeneous equipment its surveyors already had; so it had
to be compilable on as many different platforms as possible, not
just Unix and Windows systems. It is very rare to come across source
code that can be compiled on any ANSI/ISO C compiler. That makes it
far easier to port to RISC OS.

You might find these arguments, about why Lua is ideal for cell-phones,
interesting:
http://lua-users.org/lists/lua-l/2007-11/msg00248.html
They also apply to "legacy" systems like RISC OS.

Gavin Wraith

unread,
Feb 16, 2011, 10:10:51 AM2/16/11
to
In message <d8b84da...@ron1954.woosh.co.nz>
Ron <be...@woosh.co.nz> wrote:

> > For learning Lua, Roberto Ierusalimschy's book "Programming in Lua"
> > (2-nd edition, ISBN 85-903798-2-5) is the authoritative text.
> > It is a good read for anybody interested in programming, whether in
> > Lua or not. It is the first edition which is online. For those who
> > have already begun, the "Lua 5.1 Reference Manual" (ISBN 85-903798-3-3)
> > is a useful adjunct (and very slim).

> ....


> I have your HTML doc, do you perhaps have a printer friendly version?

That was created, or rather is being created, using Weave - a Lua
application I wrote to make websites - but the sources are not exactly
readable. Have you seen http://www.primopdf.com/online.aspx ?
I am not sure whether that will convert html docs to pdf. I suspect
that there may be other online pdf-creation software out there.

Ron

unread,
Feb 16, 2011, 5:47:25 PM2/16/11
to
In message <106c80a6...@wra1th.plus.com>
Gavin Wraith <ga...@wra1th.plus.com> wrote:

It's OK, !Writer will load them, for a hardcopy there will be unwanted
links to edit out and page boundaries can be set properly.
I was able to download the 5.1 manual as a PDF yesterday as well.

Ron M.

Richard Torrens (News)

unread,
Feb 17, 2011, 11:50:19 AM2/17/11
to
In article <659483a6...@wra1th.plus.com>,

Gavin Wraith <ga...@wra1th.plus.com> wrote:
> In message <51a6605ebbnews*@Torrens.org.uk>
> "Richard Torrens (News)" <News+...@Torrens.org.uk> wrote:

> > I spent an amount on Perl books, and find I don't need to do enough
> > Perl to remenmber it: at 67 I'm old enough that my forgetting curve is
> > steeper than my learning curve.

> You have my sympathies. I too bought a book on Perl, but it did not
> encourage me to use it. I am six weeks away from 72 and I am no
> longer capable of wrestling with syntactic alligators. I see from
> the TIOBE site, at
> http://www.tiobe.com/content/paperinfo/tpci/ ,
> that Perl's popularity has been in long term decline, probably
> because there are easier beasts to tame.

Perl initially looks nice because there are so many concise ways to do
things.

Problem is, if you do a lot with a small program, it becomes impossible to
work out later what you did earlier! I've done a few perl programs but
they are limited and don't encourage me back to alter them. Learning by
looking at other people's programs ... forget it!

Mostly, mine are running on a Linux server. Running locally on RISC OS ...
I tend not to!

The backup program was one exception, but I realised I could do 99% of it
with an Obey file. Much more economical! Only did in in Perl 'cos I was
trying to learn1


> > I wonder if Lua could be different: that it's so compact means it's a
> > great addition to RISC OS, especially with its interfacewith StrongED.

> That is certainly my belief. Have you seen this event, coming next
> Monday:
> http://www.rougol.jellybaby.net/meetings/index.html ?

Yes, but I'm in Cambridgeshire. Don't want to go down to London!
Especially not the other side!

> Actually I think there are two reasons why Lua is particularly
> appropriate for RISC OS. One is its compactness. The other is that
> because it was originally developed for a state institution, PetroBras,
> that was not swimming with money, it had to be made compatible with
> the heterogeneous equipment its surveyors already had; so it had
> to be compilable on as many different platforms as possible, not
> just Unix and Windows systems. It is very rare to come across source
> code that can be compiled on any ANSI/ISO C compiler. That makes it
> far easier to port to RISC OS.

I think I'm convined about its usefulness on RISC OS. It's now a matter of
finding the time and enthusiasm for programming. ATM I'm more into
learning about my various health problems and how best to handle them.

Your Lua programs with StrongED are a good advert: there needs to be a
readme in there saying what each does. I only recently discovered slashdot
which I could find very useful!

Bryan Hogan

unread,
Feb 25, 2011, 10:09:01 PM2/25/11
to
In message <51a70d5d74news*@Torrens.org.uk>

"Richard Torrens (News)" <News+...@Torrens.org.uk> wrote:

> Perl initially looks nice because there are so many concise ways to do
> things.

> Problem is, if you do a lot with a small program, it becomes
> impossible to work out later what you did earlier!

That's what I don't like about perl - it seems to encourage the
writing of bad, indecipherable, hard to debug code, and most
programmers don't need any encouragement!

>> That is certainly my belief. Have you seen this event, coming next
>> Monday:
>> http://www.rougol.jellybaby.net/meetings/index.html ?

> Yes, but I'm in Cambridgeshire. Don't want to go down to London!
> Especially not the other side!

Other side? ROUGOL is right in the middle. 200 yards south of the
Thames hardly counts as the other side!

Bryan.
--
RISC OS User Group Of London - http://www.rougol.jellybaby.net/
RISC OS London Show - http://www.riscoslondonshow.co.uk/

Martin Wuerthner

unread,
Feb 26, 2011, 5:50:25 AM2/26/11
to
In message <30b264ab...@helpful.demon.co.uk>
Bryan Hogan <sp...@nowhere.invalid> wrote:

> In message <51a70d5d74news*@Torrens.org.uk>
> "Richard Torrens (News)" <News+...@Torrens.org.uk> wrote:

>> Yes, but I'm in Cambridgeshire. Don't want to go down to London!
>> Especially not the other side!

> Other side? ROUGOL is right in the middle. 200 yards south of the
> Thames hardly counts as the other side!

200 yards can make all the difference. It was not that long ago when
it did matter a lot whether you were 200 yards to the east or 200
yards to the west of Brandenburg Gate. ;-)

--
Martin
---------------------------------------------------------------------
Martin Wuerthner MW Software http://www.mw-software.com/
RISC OS Software for Design, Printing and Publishing
---------------------------------------------------------------------

Brian Jordan

unread,
Feb 26, 2011, 6:26:27 AM2/26/11
to
In article <3df08eab...@bach.planiverse.com>, Martin Wuerthner

<spam...@mw-software.com> wrote:
> In message <30b264ab...@helpful.demon.co.uk> Bryan Hogan
> <sp...@nowhere.invalid> wrote:

> > In message <51a70d5d74news*@Torrens.org.uk> "Richard Torrens (News)"
> > <News+...@Torrens.org.uk> wrote:

> >> Yes, but I'm in Cambridgeshire. Don't want to go down to London!
> >> Especially not the other side!

> > Other side? ROUGOL is right in the middle. 200 yards south of the
> > Thames hardly counts as the other side!

> 200 yards can make all the difference. It was not that long ago when
> it did matter a lot whether you were 200 yards to the east or 200
> yards to the west of Brandenburg Gate. ;-)

But what a party when it stopped mattering.

--
______________________________________________________________________

Brian Jordan
From somewhere in North Hampshire. England. UK.
______________________________________________________________________

Richard Porter

unread,
Feb 27, 2011, 6:44:59 AM2/27/11
to
The date being 26 Feb 2011, Bryan Hogan <sp...@nowhere.invalid> decided
to write:

> Other side? ROUGOL is right in the middle. 200 yards south of the
> Thames hardly counts as the other side!

Try telling that to a cabbie!

--
Richard Porter
rich@ / www. richardporter.me.uk
"You can't have Windows without pains."

0 new messages