function varargout = problem_1_test(varargin)
% PROBLEM_1_TEST MATLAB code for problem_1_test.fig
%      PROBLEM_1_TEST, by itself, creates a new PROBLEM_1_TEST or raises the existing
%      singleton*.
%
%      H = PROBLEM_1_TEST returns the handle to a new PROBLEM_1_TEST or the handle to
%      the existing singleton*.
%
%      PROBLEM_1_TEST('CALLBACK',hObject,eventData,handles,...) calls the local
%      function named CALLBACK in PROBLEM_1_TEST.M with the given input arguments.
%
%      PROBLEM_1_TEST('Property','Value',...) creates a new PROBLEM_1_TEST or raises the
%      existing singleton*.  Starting from the left, property value pairs are
%      applied to the GUI before problem_1_test_OpeningFcn gets called.  An
%      unrecognized property name or invalid value makes property application
%      stop.  All inputs are passed to problem_1_test_OpeningFcn via varargin.
%
%      *See GUI Options on GUIDE's Tools menu.  Choose "GUI allows only one
%      instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES

% Edit the above text to modify the response to help problem_1_test

% Last Modified by GUIDE v2.5 05-Jun-2012 15:32:52

% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
                   'gui_Singleton',  gui_Singleton, ...
                   'gui_OpeningFcn', @problem_1_test_OpeningFcn, ...
                   'gui_OutputFcn',  @problem_1_test_OutputFcn, ...
                   'gui_LayoutFcn',  [] , ...
                   'gui_Callback',   []);
if nargin && ischar(varargin{1})
    gui_State.gui_Callback = str2func(varargin{1});
end

if nargout
    [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
    gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT


% --- Executes just before problem_1_test is made visible.
function problem_1_test_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject    handle to figure
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
% varargin   command line arguments to problem_1_test (see VARARGIN)

% Choose default command line output for problem_1_test
handles.output = hObject;

% Update handles structure
guidata(hObject, handles);

% UIWAIT makes problem_1_test wait for user response (see UIRESUME)
% uiwait(handles.figure1);


% --- Outputs from this function are returned to the command line.
function varargout = problem_1_test_OutputFcn(hObject, eventdata, handles) 
% varargout  cell array for returning output args (see VARARGOUT);
% hObject    handle to figure
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Get default command line output from handles structure
varargout{1} = handles.output;



function edita_Callback(hObject, eventdata, handles)
% hObject    handle to edita (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of edita as text
%        str2double(get(hObject,'String')) returns contents of edita as a double


% --- Executes during object creation, after setting all properties.
function edita_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edita (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end



function editb_Callback(hObject, eventdata, handles)
% hObject    handle to editb (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of editb as text
%        str2double(get(hObject,'String')) returns contents of editb as a double


% --- Executes during object creation, after setting all properties.
function editb_CreateFcn(hObject, eventdata, handles)
% hObject    handle to editb (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end


% --- Executes on button press in pushbutton1.
function pushbutton1_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)


%Feld B
%in edit gebe ich eine Zahl ein
B = str2num(get(handles.editb, 'String'));



%Feld A
A_gui = str2num(get(handles.edita, 'String'));  %hiere lese ich was in edit eingegeben wurde und wandle ich zu 'num' um.
A_gui_numel = numel(A_gui); 



%hier überprüfe ich, ob in A_gui ein Element vorhanden ist, nachdem ich zu
%string umgewandelt habe

if(A_gui_numel > 0)
    
    %bedeutet, dass in edit eine Zahl eingegeben wurde
    
    A = A_gui;  %dann nehme ich diesen Wert direkt an
    
else %in edit Fäche gibt es ein Variable z.B. AA
    
    A_gui_string = get(handles.edita, 'String'); %da AA string ist, nehme ich direkt an ohne str2num

    %Ab hier komme ich nicht weiter...
    %
    %Variable AA wurde in die edit-Fläche eingegeben. Ich muss hier
    %überprüfen, ob Variable AA schon vorher in MATLAB-Workspace
    %gespeichert wurde. Wenn diese Variable sich in Workspace befindet soll
    %sie benutzt werden Also, es sol so sein:
    %
    % A = AA (mit dem Wert, was AA in Workspace hat)

    
end    %Wenn es alles ok ist, soll A einen Wert haben.


%Wenn AA sich nicht in Workspace befindet oder in edit keine Zahl gegeben
%wird, bedeutet das, dass A keinen Wert hat. Dann...

if(numel(A)==0)
    errordlg('Kontrollieren Sie Ihre Eingabe für A!')
else
    %Wenn es soweit ist, kann es weiter gehen...
    Ergebnis_zahl = A*B;
    Ergebnis = num2str(Ergebnis_zahl);
    set(handeles.ergebnis, 'String', Ergebnis);
end







function ergebnis_Callback(hObject, eventdata, handles)
% hObject    handle to ergebnis (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of ergebnis as text
%        str2double(get(hObject,'String')) returns contents of ergebnis as a double


% --- Executes during object creation, after setting all properties.
function ergebnis_CreateFcn(hObject, eventdata, handles)
% hObject    handle to ergebnis (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end
