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

1 visualizzazione (ultimi 30 giorni)
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 Commenti
Adam
Adam il 28 Feb 2017
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 il 28 Feb 2017
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);

Accedi per commentare.

Risposta accettata

Adam
Adam il 28 Feb 2017
Modificato: Adam il 28 Feb 2017
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.

Più risposte (0)

Prodotti

Community Treasure Hunt

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

Start Hunting!

Translated by