function mainfcn3 ()

  [Ahandle, static, fcn_handle] = checkInput();  # A boolean variable
  output = fcn_handle ()  # executed nested function

  function [Ahandle, static, fcn_handle] = checkInput()
    %% initialize

    Ahandle = true;
    static = false;
    fcn_handle = @nestfcn;  # get a handle to nested function
  end

  function r = nestfcn ()
    keyboard;
    if (islogical(Ahandle))
      disp("Success.")
    else
      fprintf("Something went wrong: Ahandle is a %s\n", class(Ahandle))
    end
    r = 1;
  end
end
