Andreas Rozek Hints for Reading List of Recent Changes Guestbook Entry Contact the Author  Deutsche Version  HomePage Previous Topic Next Topic  First Page of Current Topic Next Page Previous Page

Lua_01 - List of Predefined (Global) Variables

"Lua_01" displays name and type (or content) of any predefined ("intrinsic") global Lua variables. In order to "beautify" the output a bit, the variable names are sorted alphabetically and positioned right justified in the list. Extremely long names (and variable contents) are truncated and marked as such with a trailing ellipsis ("...").

Again, the program is simple enough not to require any further description. "Lua_01" should be started without any command line arguments

  lua Lua_01.lua

and yields the following output:

  Lua_01 - lists all (predefined) global variables in Lua 4.0

  list of global variables:
          "_ALERT": (function)
   "_ERRORMESSAGE": (function)
          "_INPUT": (userdata)
         "_OUTPUT": (userdata)
         "_STDERR": (userdata)
          "_STDIN": (userdata)
         "_STDOUT": (userdata)
        "_VERSION": "Lua 4.0"
             "abs": (function)
          "accept": (function)
            "acos": (function)
        "appendto": (function)
           "ascii": (function)
            "asin": (function)
          "assert": (function)
            "atan": (function)
           "atan2": (function)
            "bind": (function)
            "call": (function)
            "ceil": (function)
           "clock": (function)
           "close": (function)
       "closefile": (function)
  "collectgarbage": (function)
         "connect": (function)
  "copytagmethods": (function)
             "cos": (function)
            "date": (function)
           "debug": (function)
             "deg": (function)
          "dofile": (function)
        "dostring": (function)
           "error": (function)
         "execute": (function)
            "exit": (function)
             "exp": (function)
           "floor": (function)
           "flush": (function)
         "foreach": (function)
        "foreachi": (function)
      "foreachvar": (function)
          "format": (function)
           "frexp": (function)
          "gcinfo": (function)
         "getargs": (function)
          "getenv": (function)
       "getglobal": (function)
         "getinfo": (function)
        "getlocal": (function)
            "getn": (function)
     "getpeername": (function)
     "getsockname": (function)
    "gettagmethod": (function)
         "globals": (function)
            "gsub": (function)
           "ldexp": (function)
             "log": (function)
           "log10": (function)
             "max": (function)
             "min": (function)
             "mod": (function)
          "newtag": (function)
            "next": (function)
         "nextvar": (function)
        "openfile": (function)
              "PI": 3.141592653589793
           "print": (function)
             "rad": (function)
          "random": (function)
      "randomseed": (function)
          "rawget": (function)
    "rawgetglobal": (function)
     "rawgettable": (function)
          "rawset": (function)
    "rawsetglobal": (function)
     "rawsettable": (function)
            "read": (function)
        "readfrom": (function)
         "receive": (function)
     "receivefrom": (function)
          "remove": (function)
          "rename": (function)
            "seek": (function)
          "select": (function)
            "send": (function)
          "sendto": (function)
     "setcallhook": (function)
       "setglobal": (function)
     "setlinehook": (function)
        "setlocal": (function)
       "setlocale": (function)
          "settag": (function)
    "settagmethod": (function)
             "sin": (function)
            "sort": (function)
            "sqrt": (function)
         "strbyte": (function)
         "strchar": (function)
         "strfind": (function)
          "strlen": (function)
        "strlower": (function)
          "strrep": (function)
          "strsub": (function)
        "strupper": (function)
             "tag": (function)
             "tan": (function)
         "tinsert": (function)
         "tmpname": (function)
      "tohostname": (function)
            "toip": (function)
        "tonumber": (function)
        "tostring": (function)
         "tremove": (function)
            "type": (function)
       "udpsocket": (function)
         "valueOf": (function)
           "write": (function)
         "writeto": (function)

Most of the entries shown above represent intrinsic functions - if you analyze the list a bit more carefully, you may recognize that the run-time environment used for testing this example program already includes the LuaSocket package...

Source Code

The source code of this example is available for download:

References

[1] Roberto Ierusalimschy, Luiz Henrique de Figueiredo, Waldemar Celes
Reference Manual of the Programming Language Lua 4.0
(see http://www.lua.org/manual)
the official reference manual contains any relevatn information about the language itself, the set of standard libraries and its interface to the run-time environment;

Disclaimer

Please, consider also the author's Disclaimer!

http://www.Andreas-Rozek.de/Lua/Acquainting/Lua_01_en.html    (last Modification: 14.04.2002)