| Andreas Rozek |
|
Lua_01 - Anzeige intrinsischer (globaler) Variablen"Lua_01" zeigt Namen und Typ oder Inhalt aller vordefinierten ("intrinsischen") globalen Variablen an. Um die Ausgabe etwas "hübscher" zu gestalten, werden die Namen der gefundenen Variablen alphabetisch sortiert und rechtsbündig untereinander angeordnet. Überlange Namen und Variableninhalte werden gekürzt und durch Anhängen einer "Ellipse" ("...") markiert. Auch dieses Programm ist so einfach, daß es wohl keiner weiteren Erläuterung bedarf. "Lua_01" wird ohne Angabe von Kommandozeilen-Argumenten aufgerufen lua Lua_01.lua und liefert folgende Ausgabe: 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)
Die weitaus meisten der aufgeführten globalen Variablen repräsentieren intrinsische Funktionen - wer genau hinschaut, kann vielleicht auch entdecken, daß die zur Demonstration dieses Beispielprogrammes verwendete Laufzeitumgebung das LuaSocket-Paket mit einschließt... QuelltextDas Programm steht im Quelltext zur Verfügung:
Literaturhinweise
|
| http://www.Andreas-Rozek.de/Lua/Acquainting/Lua_01.html | (letzter Stand: 14.04.2002) |