Get a value from the Lua script.
This is the central interface to retrieve values from a Lua script,
its general shape looks like
call aot_{top}_get_val(<outputs>, <id>, default)
.
Where the "outputs" are val
and errCode
. While "id" is
at least the Lua context L
. For global variables there has to
be a key
to identify the variable.
The errCode
returns an error code with various bits set for
different errors that might happen while retrieving the variable.
They can be checked by btest
and the different error codes are:
For example a check for a fatal error can be done by
btest(errCode, aoterr_fatal)
.
For the access to global variables in the Lua script the interface
therefore, looks like:
call aot_get_val(val, errCode, L, key, default)
.
The interface to access table values looks like:
call aot_get_val(val, errCode, L, thandle, key, pos, default)
.
Position pos and key are both optional, but one of them has to be provided.
If both are provided the key takes precedence over the pos, and the pos
will only be tried if the access to the key fails.
See for example get_table_real for a more detailed description of the
parameters.
Positional addressing only works intuitively as long as there have been no entries specified by keys in the table. This kind of resembles the behavior of Fortran interfaces with named or unnamed arguments, as soon as you provide a name, all following arguments have to be given by key also. Just stick to this rule for the Lua tables as well to avoid too much headache. The reason for this is, that positional addressing in Lua refers only to the unnamed entries of the tables.
Retrieve a single precision real value from a table.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=single_k), | intent(out) | :: | val | Value of the table entry if it exists. |
||
integer, | intent(out) | :: | ErrCode | Error code to indicate what kind of problem might have occured. |
||
type(flu_State) | :: | L | Handle to the Lua script. |
|||
integer, | intent(in), | optional | :: | thandle | Handle to the table to look the value up in. |
|
character(len=*), | intent(in), | optional | :: | key | Name of the entry to look for. Key and pos are both optional, however at least one of them has to be supplied. The key takes precedence over the pos if both are given. |
|
integer, | intent(in), | optional | :: | pos | Position of the entry to look for in the table. It allows the access to unnamed arrays in the Lua tables. |
|
real(kind=single_k), | intent(in), | optional | :: | default | Some default value, that should be used, if the variable is not set in the Lua script. |
Retrieve a double precision real value from a table.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=double_k), | intent(out) | :: | val | Value of the table entry if it exists. |
||
integer, | intent(out) | :: | ErrCode | Error code to indicate what kind of problem might have occured. |
||
type(flu_State) | :: | L | Handle to the Lua script. |
|||
integer, | intent(in), | optional | :: | thandle | Handle to the table to look the value up in. |
|
character(len=*), | intent(in), | optional | :: | key | Name of the entry to look for. Key and pos are both optional, however at least one of them has to be supplied. The key takes precedence over the pos if both are given. |
|
integer, | intent(in), | optional | :: | pos | Position of the entry to look for in the table. It allows the access to unnamed arrays in the Lua tables. |
|
real(kind=double_k), | intent(in), | optional | :: | default | Some default value, that should be used, if the variable is not set in the Lua script. |
Retrieve a default integer value from a table.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer(kind=int_k), | intent(out) | :: | val | Value of the table entry if it exists. |
||
integer, | intent(out) | :: | ErrCode | Error code to indicate what kind of problem might have occured. |
||
type(flu_State) | :: | L | Handle to the Lua script. |
|||
integer, | intent(in), | optional | :: | thandle | Handle to the table to look the value up in. |
|
character(len=*), | intent(in), | optional | :: | key | Name of the entry to look for. Key and pos are both optional, however at least one of them has to be supplied. The key takes precedence over the pos if both are given. |
|
integer, | intent(in), | optional | :: | pos | Position of the entry to look for in the table. It allows the access to unnamed arrays in the Lua tables. |
|
integer(kind=int_k), | intent(in), | optional | :: | default | Some default value, that should be used, if the variable is not set in the Lua script. |
Retrieve a long integer value from a table.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer(kind=long_k), | intent(out) | :: | val | Value of the table entry if it exists. |
||
integer, | intent(out) | :: | ErrCode | Error code to indicate what kind of problem might have occured. |
||
type(flu_State) | :: | L | Handle to the Lua script. |
|||
integer, | intent(in), | optional | :: | thandle | Handle to the table to look the value up in. |
|
character(len=*), | intent(in), | optional | :: | key | Name of the entry to look for. Key and pos are both optional, however at least one of them has to be supplied. The key takes precedence over the pos if both are given. |
|
integer, | intent(in), | optional | :: | pos | Position of the entry to look for in the table. It allows the access to unnamed arrays in the Lua tables. |
|
integer(kind=long_k), | intent(in), | optional | :: | default | Some default value, that should be used, if the variable is not set in the Lua script. |
Retrieve a string from a table.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*) | :: | val | Value of the table entry if it exists. |
|||
integer, | intent(out) | :: | ErrCode | Error code to indicate what kind of problem might have occured. |
||
type(flu_State) | :: | L | Handle to the Lua script. |
|||
integer, | intent(in), | optional | :: | thandle | Handle to the table to look the value up in. |
|
character(len=*), | intent(in), | optional | :: | key | Name of the entry to look for. Key and pos are both optional, however at least one of them has to be supplied. The key takes precedence over the pos if both are given. |
|
integer, | intent(in), | optional | :: | pos | Position of the entry to look for in the table. It allows the access to unnamed arrays in the Lua tables. |
|
character(len=*), | intent(in), | optional | :: | default | Some default value, that should be used, if the variable is not set in the Lua script. |
Retrieve a logical value from a table.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
logical, | intent(out) | :: | val | Value of the table entry if it exists. |
||
integer, | intent(out) | :: | ErrCode | Error code to indicate what kind of problem might have occured. |
||
type(flu_State) | :: | L | Handle to the Lua script. |
|||
integer, | intent(in), | optional | :: | thandle | Handle to the table to look the value up in. |
|
character(len=*), | intent(in), | optional | :: | key | Name of the entry to look for. Key and pos are both optional, however at least one of them has to be supplied. The key takes precedence over the pos if both are given. |
|
integer, | intent(in), | optional | :: | pos | Position of the entry to look for in the table. It allows the access to unnamed arrays in the Lua tables. |
|
logical, | intent(in), | optional | :: | default | Some default value, that should be used, if the variable is not set in the Lua script. |
Retrieve a userdata value (generic C pointer) from a table.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(c_ptr), | intent(out) | :: | val | Value of the table entry if it exists. |
||
integer, | intent(out) | :: | ErrCode | Error code to indicate what kind of problem might have occured. |
||
type(flu_State) | :: | L | Handle to the Lua script. |
|||
integer, | intent(in), | optional | :: | thandle | Handle to the table to look the value up in. |
|
character(len=*), | intent(in), | optional | :: | key | Name of the entry to look for. Key and pos are both optional, however at least one of them has to be supplied. The key takes precedence over the pos if both are given. |
|
integer, | intent(in), | optional | :: | pos | Position of the entry to look for in the table. It allows the access to unnamed arrays in the Lua tables. |
|
type(c_ptr), | intent(in), | optional | :: | default | Some default value, that should be used, if the variable is not set in the Lua script. |