open_config_chunk Subroutine

public subroutine open_config_chunk(L, chunk, ErrCode, ErrString)

Subroutine to load and execute a script given in a string.

Arguments

Type IntentOptional Attributes Name
type(flu_State) :: L

Handle to the Lua script

character(len=*), intent(in) :: chunk

String with Lua code to load.

integer, intent(out), optional :: ErrCode

Error code returned by Lua during loading or executing the file.

This optional parameter might be used to react on errors in the calling side. If neither ErrCode nor ErrString are given, this subroutine will stop the program execution and print the error message from Lua to the stdout.

character(len=*), intent(out), optional :: ErrString

Obtained error description from the Lua stack.

This optional argument holds the Lua error message in case something went wrong. It can be used to provide some feedback to the user in the calling routine. If neither ErrCode nor ErrString are provided, open_config() will print the error message and stop program execution.


Calls

proc~~open_config_chunk~~CallsGraph proc~open_config_chunk open_config_chunk proc~aot_err_handler aot_err_handler proc~open_config_chunk->proc~aot_err_handler proc~flu_isopen flu_isopen proc~open_config_chunk->proc~flu_isopen proc~flu_pcall flu_pcall proc~open_config_chunk->proc~flu_pcall proc~flul_loadstring fluL_loadstring proc~open_config_chunk->proc~flul_loadstring proc~flul_newstate fluL_newstate proc~open_config_chunk->proc~flul_newstate proc~flul_openlibs fluL_openlibs proc~open_config_chunk->proc~flul_openlibs proc~flu_tolstring flu_tolstring proc~aot_err_handler->proc~flu_tolstring interface~lua_pcallk lua_pcallk proc~flu_pcall->interface~lua_pcallk interface~lual_loadstring luaL_loadstring proc~flul_loadstring->interface~lual_loadstring interface~lual_newstate luaL_newstate proc~flul_newstate->interface~lual_newstate interface~lual_openlibs luaL_openlibs proc~flul_openlibs->interface~lual_openlibs interface~lua_tolstring lua_tolstring proc~flu_tolstring->interface~lua_tolstring

Source Code

  subroutine open_config_chunk(L, chunk, ErrCode, ErrString)
    type(flu_State) :: L !! Handle to the Lua script

    !> String with Lua code to load.
    character(len=*), intent(in) :: chunk

    !> Error code returned by Lua during loading or executing the file.
    !!
    !! This optional parameter might be used to react on errors in the calling
    !! side. If neither ErrCode nor ErrString are given, this subroutine will
    !! stop the program execution and print the error message from Lua to the
    !! stdout.
    integer, intent(out), optional :: ErrCode

    !> Obtained error description from the Lua stack.
    !!
    !! This optional argument holds the Lua error message in case something
    !! went wrong. It can be used to provide some feedback to the user in the
    !! calling routine. If neither ErrCode nor ErrString are provided,
    !! open_config() will print the error message and stop program execution.
    character(len=*), intent(out), optional :: ErrString

    integer :: err

    if (.not.flu_isopen(L)) L = fluL_newstate()

    err = fluL_loadstring(L, chunk)

    call aot_err_handler(L, err, 'Cannot load chunk:', ErrString, ErrCode)

    if (err == 0) then
      call fluL_openlibs(L)

      err = flu_pcall(L, 0, 0, 0)

      call aot_err_handler(L, err, 'Cannot run chunk:', ErrString, ErrCode)
    end if

  end subroutine open_config_chunk