I'd like to create an edit box that takes in commands I'll be using in my algorithm and save those commands to another edit/listbox to be used again. Can anybody help? I'm using GUIDE for my GUI. Thanks!
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @GeneralPlotter_OpeningFcn, ...
'gui_OutputFcn', @GeneralPlotter_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 GeneralPlotter is made visible.
function GeneralPlotter_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 GeneralPlotter (see VARARGIN)
% Choose default command line output for GeneralPlotter
handles.output = hObject;
if isempty(varargin)
handles.gp = GenericPlotter();
else
handles.gp = [];
end
set(handles.edit3,'string','')
handles.Counter = 0;
% Update handles structure
guidata(hObject, handles);
% --- Executes on button press in pushbutton5.
function pushbutton5_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton5 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
%// Counter to know how many functions you added
handles.Counter = 0;
%// Pushbutton's callback. Get the string in the edit box and append it
%// to the listbox content. Delete the 1st entry since its intially empty
CurrentCommand = cellstr(get(handles.edit3,'String'));
CurrentHistory = cellstr(get(handles.listbox4,'String'));
NewHistory = vertcat(CurrentHistory,CurrentCommand);
%// Remove 1st empty entry on 1st press of the button
if handles.Counter == 0
NewHistory(1) = [];
end
set(handles.listbox4,'String',NewHistory)
handles.Counter = handles.Counter + 1;
guidata(hObject,handles)