Search All of the Math Forum:
Views expressed in these public forums are not endorsed by
Drexel University or The Math Forum.
|
|
Alex
Posts:
16
Registered:
2/11/11
|
|
list box removing path
Posted:
Feb 2, 2013 6:49 PM
|
|
I have a gui with 2 listboxes that contain the same files, one with pathname + filename, the other with just the filenames. I have the listbox populated with filenames shown, while the listbox containg the paths hidden under an axes (so that I only have to look at the filenames, and not their path too). The problem I'm having is that if I add files from more than one path, only the paths of the most recently files added are kept, and the paths of the other files are removed leaving only the the filename. I dont know why this is happening, and thanks on advance for any help!
for the code below: inputFiles_listbox holds only the filenames namefile_listbox holds the pathname+filename
% --- Executes on button press in add_file. function add_file_Callback(hObject, eventdata, handles)
global input_file global newNames
% gets input file(s) from user [input_file,pathname] = uigetfile( ... {'*.asc', 'ASCII (*.asc)'; ... '*.*', 'All Files (*.*)'}, ... 'Select files', ... 'MultiSelect', 'on',... '/home/smfiles');
% if file selection is cancelled, pathname should be zero and nothing should happen if pathname == 0 return end
% assignin('base','pathname',pathname) % handles.pathname = pathname; % Holds pathname in handles structure to be passed to output files.
% gets the current data file names inside the listbox newFileNames = get(handles.inputFiles_listbox,'String'); inputFileNames = get(handles.inputFiles_listbox,'String');
% if only one file is selected, then the data will not be a cell % if more than one file selected at once, then the data will be stored inside a cell if iscell(input_file) == 0 %add the most recent data file selected to the cell containing all the data file names newFileNames{end+1} = fullfile(pathname,input_file); inputFileNames{end+1} = fullfile(input_file); else % data will be in cell format for n = 1:length(input_file) % braces, {}, are used because cells are being used. newFileNames{end+1} = fullfile(pathname,input_file{n}) inputFileNames{end+1} = fullfile(input_file{n}) end end
% updating the gui to display all filenames in the listbox set(handles.namefile_listbox,'String',newFileNames) set(handles.inputFiles_listbox,'String',inputFileNames)
% make sure first file is always selected so it doesn't go out of range % the GUI will break if this value is out of range set(handles.namefile_listbox,'Value',1); set(handles.inputFiles_listbox,'Value',1);
% Update handles structure guidata(hObject, handles);
|
|
|
Date
|
Subject
|
Author
|
|
2/2/13
|
|
Alex
|
|
2/2/13
|
|
Alex
|
|
|