Calling a GUI from another GUI. Problem with output variable being overwritten.

1 次查看(过去 30 天)
I currently have a GUI, Main, that will call another GUI, More. More is called and opened on a button press in Main and it shows a list of variables. This list can have more variables added to it and the list is saved to a cell array. More needs to output this array back to Main when the button Done is pressed.
Right now, More works on its own to take an initial input array, put it in the listbox, and can have more added to the array and listbox. It will also correctly output the new array of all the values in the listbox.
The problem comes when I run Main and call More. The inputs work fine and More can have variables added to it but once Done is pressed and More is closed, the array is completely overwritten. It's like Main re-initializes the array after More is closed.
If anyone can help me fix this, it would be greatly appreciated!
  2 个评论
Adam
Adam 2017-2-28
You haven't given any information on the crucial part of the operation - i.e. how you implemented the part where clicking 'Done' transfers the data back to the main GUI.
Ashleen Hayes
Ashleen Hayes 2017-2-28
I call uiwait in the opening function and uiresume when Done is pressed to set the outputs and close the figure. The output of More is the array of variables.
This is the line of code in Main that calls More and gets the outputted array
[handles.array] = More(handles.initialarray);

请先登录,再进行评论。

采纳的回答

Adam
Adam 2017-2-28
编辑:Adam 2017-2-28
Judging from what you are saying and the symptoms, without seeing the whole code, I suspect you are missing a
guidata( hObject, handles )
(or equivalent) line after calling your More GUI and assigning its results into handles. Without this line the copy of handles you have in the function you launch your 2nd GUI from will just go out of scope and you will still have the original version of handles with the old 'array' field on it.

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Whos 的更多信息

产品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by