Syntax
isvalidlevel(level: number): booleanvalidleveldebug.isvalidleveldebug.validlevelArguments
| Name | Type | Description |
|---|---|---|
level | number | Stack level number converted to an integer and checked against 0 <= level < the current call stack depth. |
Returns
| Name | Type | Description |
|---|---|---|
valid | boolean | true when the numeric level is within the current call stack range, otherwise false. |
Description
Checks whether a numeric stack level is within the current call stack range. level is required and must be a number because the function calls requires a number. The value is converted to an integer. The function returns false when level < 0 or level >= the current call stack depth, otherwise true. It does not inspect the frame closure and does not raise "Level out of range" for invalid numeric levels. validlevel is a global alias, and debug.isvalidlevel plus debug.validlevel are exposed with the debug table aliases.
Call it with 1 parameter(s): level. The argument table explains which values are required and which ones only refine the behavior.
It returns valid (boolean). Use the returns table to separate successful values from nil results and recoverable errors.
Example
Check whether a numeric stack level is inside the current call stack range.
print(isvalidlevel(0))
print(validlevel(0))
print(debug.isvalidlevel(0))
print(debug.validlevel(0))