extracting info from edit text gui

8 views (last 30 days)
sundeep cheruku
sundeep cheruku on 24 Jun 2011
[EDIT: 20110625 - reformat - WDR]
Please help me with this
function [] = clear_edit_example()
% Show how to clear and editbox string when cursor is placed over it.
S.fh = figure('units','pixels',...
'position',[500 500 300 50],...
'menubar','none',...
'numbertitle','off',...
'name','clear_edit_example',...
'resize','off');
S.ed = uicontrol('style','edit',...
'units','pixels',...
'position',[10 10 280 30],...
'fontsize',14,...
'string','Enter Value');
set(S.fh,'windowbuttonmotionfcn',{@fh_bmfcn,S})
This is the code and i want to use the data of editbox externally for some other purpose... someone please help me with this...

Answers (1)

Arturo Moncada-Torres
Arturo Moncada-Torres on 24 Jun 2011
To extract the data (text) from the edit box, you will need something more or less like this:
% Get the string from the editText box.
myText = get(S.ed, 'String');
EDIT
When you run a GUI, the variables' scope is only within the GUI. If you want to be able to manipulate that variable later, save the variable into a .mat file and load it later. For example:
% Get the string.
myText = get(S.ed, 'String');
% Save the variable into a .mat file.
save('myTextVariable', 'myText');
Later, to recover it:
% Load the variable for later use.
load('myTextVariable', 'myText');
Try it and let me know if it works ;-)
  2 Comments
sundeep cheruku
sundeep cheruku on 24 Jun 2011
inside the function the value works fine... but when i check in the matlab prompt.. it shows 'text' is undefined variable..

Sign in to comment.

Categories

Find more on Characters and Strings in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!