Exercises, examples and other material relating to training module U110. This topic is presented on public courses Learning to program in Lua
, Lua Programming
, Lua Programming
|Articles and tips on this subject||updated|
|3558||Python or Lua - which should I use / learn?|
"Should I learn and use Python or Lua" - a question to me. The questioner was perceptive, knowing that he shouldn't try to learn lots of languages at the same time, and that he should always limit the "basket" of languages used within his applications - in fact, he was wondering if he could select just ...
|2344||Reading a data file and sensing EOF in Lua|
In Lua, the standard table io includes an io.open code element that lets you open a file. This returns a userdata to you (looks like a table but isn't - it's a C accessible structure) from which you can run the read code. Empty lines return an empty string (in Lua this is a TRUE value, unlike other languages), ...
|1841||Formatting with a leading + / Lua and Perl|
In formatted printing, you can often use a leading "+" in the format string to force a positive sign to be added in front of positive numbers - for example "%+4d" means an integer, to base 10, 4 character positions as a minimum, right justified.
Here's an example of that, in code, in Lua
for john = ...
|1744||Lua examples, Lua Courses|
Programming training is much more effective if the delegates are shown how a particular program is written, rather than just the final result ... show them just the final result and they'll ask "but how did you come up with that?"
So whenever possible, I write new examples in front of my delegates - ...
Examples from our training material
|boring|| File open, read|
|emmas|| Looking for (and counting) email addresses in a log file|
|filescan|| Finding the latest log file and analysing it (popen, ls)|
|flapper|| file read and write - line by line|
|flipper|| keyboard and screen read and write|
|grounds.lua|| Soccer grounds - Lua|
|info.txt|| Soccer ground data for Lua and Python example|
|log_counter|| Command line and data file use / full course example|
|loganal|| Log file analysis|
|skill_lister|| Processing a file of records, splitting each record|
|zz|| Some file reading fundamentals|
Some modules are available for download
as a sample of our material or under an Open Training Notes License
for free download from [here]
Topics covered in this module
Keyboard and screen at a lower level
Opening and closing files.
Reading and writing files.
File status checks and file system operations.
Other file system functions.
If you are looking for a complete course and not just a information on a single subject, visit our Listing and schedule
Well House Consultants specialise in training courses in
. We run
throughout the UK (and beyond for longer courses), and
at our training centre in Melksham, Wiltshire, England.
It's surprisingly cost effective to come on our public courses -
even if you live in a different
country or continent to us
We have a technical library of over 700 books on the subjects on which we teach.
These books are available for reference at our training centre.