Clear Filters
Clear Filters

Create a static text box that displays a number, then adds one every time the GUI is opened.

1 view (last 30 days)
I am trying to create a static text box that displays the value 'R0000001'. Then from that point on, every time the GUI opens or the "New" option from the tool bar is clicked the static text box displays the next value up.
For example when I open the GUI for the first time the static text box displays 'R0000001'. Then I choose "New" it will display 'R0000002'.After that I close it and reopen it again it will display "R0000003' ... and so on.
This GUI will be compiled to be a standalone application to be used by users that do not have MATLAB installed.
Is this possible?

Accepted Answer

Azzi Abdelmalek
Azzi Abdelmalek on 23 May 2013
In your opening function
s=char(get(handles.text1,'string'));
n=num2str(str2num(s(2:end))+1);
s(end-numel(n)+1:end)=n
set(handles.text1,'string',s)
  3 Comments
Azzi Abdelmalek
Azzi Abdelmalek on 23 May 2013
No, use a mat-file
In windows command, create a mat-file
s='R0000001'
save filename s
In your opening function
s=load('filename');
s=s.s
n=num2str(str2num(s(2:end))+1);
s(end-numel(n)+1:end)=n
set(handles.text1,'string',s)
save filename s

Sign in to comment.

More Answers (0)

Categories

Find more on Programming Utilities in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!