I have made a GUI where I am dynamically generating a name for saving a plot. The name is determined by inputs the user puts in to different edit boxes. However, the most frequently edited edit box where I ask the user to put in a "mode" or specific characteristic of the plot being saved, isn't always caught by the program and used for the file name.
For example, in this edit box I may put something to the affect of "ac mode_Port 1", and in the callback for the edit box I get what I input, but sometimes the previous string I input into the edit box is used when the plot saves.
I have done some debugging, and I know that my edit box callback is getting the correct string and that it is being saved to the handles.Mod variable I create. But When I call handles.Mod in another function for saving it does not always work. This error happen inconsistently, infrequently, and I am unable to reproduce it on my own accord.
Here is my code for my edit box call back…
function edit_Mod_Callback(hObject, eventdata, handles) Mod = get(hObject,'string'); handles.Mod = Mod; display(handles.Mod); guidata(hObject,handles)
The display in this code always prints in the command window my expected string.
The following code is where i call "handles.Mod".
if true function pb_SvScn_Callback(hObject, eventdata, handles) String = StrSv(handles.BW,handles.CF,handles.Mod); display(handles.Mod); j=('.gif'); FileName=strcat(handles.TT,String,j); saveName = strcat(handles.Path,'\',FileName); h = findobj('Tag','pb_GetImg'); data = h.UserData; imwrite(data.x,data.map,saveName); d = datestr(now,'HH:MM AM'); str1 = ' was saved to the specified folder at '; update = strcat(FileName, str1, d); set(handles.text_Update, 'String', update);end
The "display(handles.Mod)" in the function "pb_SvScn_Callback" sometimes prints the previous string I input for the last plot I saved.
I'm unsure what the issue may be. Perhaps in my call for handles.Mod I am doing something improper.
Any information or suggestions would be most appreciated.
Thanks so much.
-Jason
Best Answer