function varargout = GUI_batch_script(varargin)
% GUI_BATCH_SCRIPT M-file for GUI_batch_script.fig
%      GUI_BATCH_SCRIPT, by itself, creates a new GUI_BATCH_SCRIPT or raises the existing
%      singleton*.
%
%      H = GUI_BATCH_SCRIPT returns the handle to a new GUI_BATCH_SCRIPT or the handle to
%      the existing singleton*.
%
%      GUI_BATCH_SCRIPT('CALLBACK',hObject,eventData,handles,...) calls the local
%      function named CALLBACK in GUI_BATCH_SCRIPT.M with the given input arguments.
%
%      GUI_BATCH_SCRIPT('Property','Value',...) creates a new GUI_BATCH_SCRIPT or raises the
%      existing singleton*.  Starting from the left, property value pairs are
%      applied to the GUI before GUI_batch_script_OpeningFunction gets called.  An
%      unrecognized property name or invalid value makes property application
%      stop.  All inputs are passed to GUI_batch_script_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 GUI_batch_script

% Last Modified by GUIDE v2.5 19-Oct-2005 14:05:10

% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
                   'gui_Singleton',  gui_Singleton, ...
                   'gui_OpeningFcn', @GUI_batch_script_OpeningFcn, ...
                   'gui_OutputFcn',  @GUI_batch_script_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 GUI_batch_script is made visible.
function GUI_batch_script_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 GUI_batch_script (see VARARGIN)

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

% Update handles structure
guidata(hObject, handles);

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

  set(handles.e_mail_addy,'String', '');

%If BATCH exist - use it to set initial parameters
 
if ~isempty(BATCH)
  set(handles.num_proc,'String', BATCH.num_proc) ;
  set(handles.wall_time,'String', BATCH.wall_time) ;
  set(handles.prj_name,'String', BATCH.prj_name);
  set(handles.stdout_file,'String', BATCH.stdout_file);
  set(handles.stderr_file,'String', BATCH.stderr_file);
  set(handles.a_type,'String', BATCH.a_type);
  set(handles.e_mail_addy,'String', BATCH.e_mail_addy);
end

% --- Outputs from this function are returned to the command line.
function varargout = GUI_batch_script_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 num_proc_Callback(hObject, eventdata, handles)
% hObject    handle to num_proc (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 num_proc as text
%        str2double(get(hObject,'String')) returns contents of num_proc as a double


% --- Executes during object creation, after setting all properties.
function num_proc_CreateFcn(hObject, eventdata, handles)
% hObject    handle to num_proc (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 wall_time_Callback(hObject, eventdata, handles)
% hObject    handle to wall_time (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 wall_time as text
%        str2double(get(hObject,'String')) returns contents of wall_time as a double


% --- Executes during object creation, after setting all properties.
function wall_time_CreateFcn(hObject, eventdata, handles)
% hObject    handle to wall_time (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 prj_name_Callback(hObject, eventdata, handles)
% hObject    handle to prj_name (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 prj_name as text
%        str2double(get(hObject,'String')) returns contents of prj_name as a double


% --- Executes during object creation, after setting all properties.
function prj_name_CreateFcn(hObject, eventdata, handles)
% hObject    handle to prj_name (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 stdout_file_Callback(hObject, eventdata, handles)
% hObject    handle to stdout_file (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 stdout_file as text
%        str2double(get(hObject,'String')) returns contents of stdout_file as a double


% --- Executes during object creation, after setting all properties.
function stdout_file_CreateFcn(hObject, eventdata, handles)
% hObject    handle to stdout_file (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 stderr_file_Callback(hObject, eventdata, handles)
% hObject    handle to stderr_file (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 stderr_file as text
%        str2double(get(hObject,'String')) returns contents of stderr_file as a double


% --- Executes during object creation, after setting all properties.
function stderr_file_CreateFcn(hObject, eventdata, handles)
% hObject    handle to stderr_file (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 a_type_Callback(hObject, eventdata, handles)
% hObject    handle to a_type (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 a_type as text
%        str2double(get(hObject,'String')) returns contents of a_type as a double


% --- Executes during object creation, after setting all properties.
function a_type_CreateFcn(hObject, eventdata, handles)
% hObject    handle to a_type (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 e_mail_addy_Callback(hObject, eventdata, handles)
% hObject    handle to e_mail_addy (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 e_mail_addy as text
%        str2double(get(hObject,'String')) returns contents of e_mail_addy as a double


% --- Executes during object creation, after setting all properties.
function e_mail_addy_CreateFcn(hObject, eventdata, handles)
% hObject    handle to e_mail_addy (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 script_create.
function script_create_Callback(hObject, eventdata, handles)
% hObject    handle to script_create (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

global BATCH

%Create a MATLAB structure with the parameters of the batch mode
 
  BATCH.num_proc = str2num(get(handles.num_proc,'String'));
  BATCH.wall_time = get(handles.wall_time,'String');
  BATCH.prj_name = get(handles.prj_name,'String');
  BATCH.stdout_file = get(handles.stdout_file,'String');
  BATCH.stderr_file = get(handles.stderr_file,'String');
  BATCH.a_type = get(handles.a_type,'String');
  BATCH.e_mail_addy = get(handles.e_mail_addy,'String');

close(GUI_batch_script);

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

close(GUI_batch_script);


