[Home] [Downloads] [Search] [Help/forum]

debug.getlocal

Summary

Returns name and value of a local variable

Prototype

name, val = debug.getlocal (level, local)


Description

Returns the name and value of the local variable with the index 'local' of the function at 'level' on the stack.
See also debug.setlocal .


function f (a, b)
local c = 11
local i = 1

repeat
  name, val = debug.getlocal (1, i)
  if name then
    print ("index", i, name, "=", val)
    i = i + 1
  end -- if
until not name

end -- function f

f (22, 33)

 -->

index 1 a = 22
index 2 b = 33
index 3 c = 11
index 4 i = 4


See Also ...

Lua functions

debug.debug - Enters interactive debugging
debug.getfenv - Returns the environment of an object
debug.gethook - Returns the current hook settings
debug.getinfo - Returns a table with information about a function
debug.getmetatable - Returns the metatable of the given object
debug.getregistry - Returns the registry table
debug.getupvalue - Returns the name and value of an upvalue
debug.setfenv - Sets the environment of an object
debug.sethook - Sets a debug hook function
debug.setlocal - Sets the value of the local variable
debug.setmetatable - Sets the metatable for an object
debug.setupvalue - Sets an upvalue for a function
debug.traceback - Returns a string with a traceback of the stack call

Topics

Lua base functions
Lua bc (big number) functions
Lua bit manipulation functions
Lua coroutine functions
Lua debug functions
Lua io functions
Lua math functions
Lua os functions
Lua package functions
Lua PCRE regular expression functions
Lua script extensions
Lua string functions
Lua syntax
Lua table functions
Lua utilities
Scripting
Scripting callbacks - plugins

(Help topic: lua=debug.getlocal)

Documentation contents page


Search ...

Enter a search string to find matching documentation.

Search for:   

Quick links: MUSHclient. MUSHclient help. Forum shortcuts. Posting templates. Lua modules. Lua documentation.

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.

[Home]


Written by Nick Gammon - 5K   profile for Nick Gammon on Stack Exchange, a network of free, community-driven Q&A sites   Marriage equality

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( https://gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Hosted at FutureQuest]