Editboxes in a Script

조회 수: 1(최근 30일)
James Tammen
James Tammen 2013년 9월 13일
I have a script to run a GUI menu in order to tie together a list of different scripts/functions so that they can run overnight without manual input. I already have a pushbutton and several checkboxes that are functional.
close all
if ~exist('utilcode'); utilcode='';end
positiona=[30 550 120 20];
BuildHr8=uicontrol('Style','checkbox','string','Build Hr8 Files','position',position2);
I am able to get a good return on the checkboxes, but the editboxes return a blank matrix.
I tried doing this with functions, but the variables would be replaced with random numbers (not to mention moving variables became a headache.
  댓글 수: 1
Arthur 2013년 9월 13일
How to you read the the String from the textbox?

댓글을 달려면 로그인하십시오.


Image Analyst
Image Analyst 2013년 9월 13일
Did you try the get() function to retrieve the current contents of the edit box?
contentsOfEditbox = get(utility, 'String');

James Tammen
James Tammen 2013년 9월 16일
편집: Walter Roberson 2013년 9월 16일
I tried using functions such as
function h_utility(hObject,eventdata,Convert,Build,Update)
function h_GO(utilcode,ReadFilesAfterDate,ReadSubdirs,Convert,Build,Update)
close all
The function h_utility recognizes the input (i.e. I type in abc, it returns abc), but in function h_GO it returns a number in the utilcode input as 5.0037 and the get() function returns an error of too many input arguments (which doesn't make sense to me).
  댓글 수: 5
Image Analyst
Image Analyst 2013년 9월 19일
Yeah, that seems weird to me that your intranet won't let you load a .fig file. If not, then you're stuck "rolling your own" via a boatload of tedious m-file statements.

댓글을 달려면 로그인하십시오.

Walter Roberson
Walter Roberson 2013년 9월 16일
is going to run the function h_utility and take its return value as the list of handles whose String property is to be fetched. But the function h_utility not defined to return any value. That would lead to an error.
Note that when you execute h_utility, the variable you write to, utilcode, is a local variable, so the value of that variable is discarded after the get()
Perhaps the above is not your actual code?
  댓글 수: 2
Walter Roberson
Walter Roberson 2013년 9월 16일
Please look in the file exchange for the 41 Complete Sample GUIs contribution.

댓글을 달려면 로그인하십시오.

Arthur 2013년 9월 16일
You need to pass on the handle of your textbox to the function that has to read out the textbox. The common way to do this is by creating a handles struct, containing all the handles of your GUI.
Easy methods to do this is by using the function guidata, or by using getappdata/setappdata.
  댓글 수: 2
Image Analyst
Image Analyst 2013년 9월 20일
See how hard it is if you're going to do all the gory details yourself? Anyway, please be specific about what function is "the first function", what function is "the secound function", and exactly what gets converted to 155.0142 (which looks just like the value of a handle.)

댓글을 달려면 로그인하십시오.


Find more on Migrate GUIDE Apps in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by