aot_top_get_string Subroutine

private subroutine aot_top_get_string(val, ErrCode, L, default)

Interpret topmost entry on Lua stack as a single precision real.

Arguments

Type IntentOptional Attributes Name
character(len=*) :: val

Value of the Variable in the script

integer, intent(out) :: ErrCode

Error code to indicate what kind of problem might have occured.

type(flu_State) :: L

Handle to the Lua script

character(len=*), intent(in), optional :: default

Some default value, that should be used, if the variable is not set in the Lua script.


Calls

proc~~aot_top_get_string~~CallsGraph proc~aot_top_get_string aot_top_get_string proc~flu_isnoneornil flu_isNoneOrNil proc~aot_top_get_string->proc~flu_isnoneornil proc~flu_isstring flu_isString proc~aot_top_get_string->proc~flu_isstring proc~flu_pop flu_pop proc~aot_top_get_string->proc~flu_pop proc~flu_tolstring flu_tolstring proc~aot_top_get_string->proc~flu_tolstring interface~lua_type lua_type proc~flu_isnoneornil->interface~lua_type interface~lua_isstring lua_isString proc~flu_isstring->interface~lua_isstring interface~lua_settop lua_settop proc~flu_pop->interface~lua_settop interface~lua_tolstring lua_tolstring proc~flu_tolstring->interface~lua_tolstring

Called by

proc~~aot_top_get_string~~CalledByGraph proc~aot_top_get_string aot_top_get_string interface~aot_top_get_val aot_top_get_val interface~aot_top_get_val->proc~aot_top_get_string

Source Code

  subroutine aot_top_get_string(val, ErrCode, L, default)
    type(flu_State) :: L !! Handle to the Lua script

    !> Value of the Variable in the script
    character(len=*) :: val

    !> Error code to indicate what kind of problem might have occured.
    integer, intent(out) :: ErrCode

    !> Some default value, that should be used, if the variable is not set in
    !! the Lua script.
    character(len=*), optional, intent(in) :: default

    logical :: not_retrievable
    character, pointer :: cstring(:)
    integer :: i, StrLen, StrLimit

    ErrCode = 0
    not_retrievable = .false.

    if (flu_isNoneOrNil(L, -1)) then
      ErrCode = ibSet(ErrCode, aoterr_NonExistent)
      not_retrievable = .true.
    else
      if (flu_isString(L, -1)) then
        cstring => flu_toLString(L, -1, StrLen)
        StrLimit = min(StrLen, len(val))
        val = ''
        do i=1,StrLimit
          val(i:i) = cstring(i)
        end do
      else
        ErrCode = ibSet(ErrCode, aoterr_WrongType)
        ErrCode = ibSet(ErrCode, aoterr_Fatal)
        not_retrievable = .true.
      end if
    end if

    if (not_retrievable) then
      if (present(default)) then
        val = default
      else
        ErrCode = ibSet(ErrCode, aoterr_Fatal)
      end if
    end if
    call flu_pop(L)

  end subroutine aot_top_get_string