MATLAB: How to use pre-defined data in *_CreateFcn calls in GUIDE

guiguide

Hello,
I am a self-described 'modest' Matlab programmer and have recently started coming back up to speed on GUIDE for my work.
My situation is that I have roughly three dozen components on my GUI, and I would like to have a large number of them initialized based on 'pre-defined' data that I have hard-coded somewhere in a central location. I say central as I would like to use some pieces of data be used to initialize multiple components. A quick example of what I want is if I had two text boxes on my GUI:
function text_box1_CreateFcn(hObject, eventdata, handles)
set(hObject, 'string', handles.paramA)
function text_box2_CreateFcn(hObject, eventdata, handles)
set(hObject, 'string', handles.paramA)
Where handles.paramA has been set 'before' the code gets to this point.
Further Discussion
I know that I can do what I want by setting both text boxes in the OpeningFcn() function with:
set(handles.text_box#, 'string', handles.paramA)
but you can imagine that OpeningFcn() would get quite large as I have significantly more than two components to set, and some of the initialization I am doing involves blocks of logic rather than just single lines. Is this route my best bet? I think the crux of my problem is that all CreateFcn() calls are executed before OpeningFcn(), correct?

Best Answer

I would say yes you have to do it from the OpeningFcn, but that doesn't mean all the code has to be in the OpeningFcn.
My OpeningFcn in Uis tends to call a string of other functions like
initialiseSomeSliders( handles )
initialiseSomeOtherSliders( handles )
initialiseAxes( handles )
Obviously you can delegate to as many or as few functions as you like and my functions often further delegate anyway so the OpeningFcn usually stays tidy and relatively short.
I don't used the createFcn's myself (I even delete them all if I can be bothered), but I would imagine that they get called before OpeningFcn so you can't access data attached to handles in them, only the handles of other UI components.