Matlab GUIDE Display Current Date in Edit Text box - matlab

I am making my very first GUI using GUIDE and I am running into a problem with one of my Edit Text boxes. The Edit Text box will require the user to enter a date using the mm/dd/yyyy format. I expect that the user will be entering the current date 99% of the time, so I would like to have the current date (in mm/dd/yyyy format) already entered in the text box for the user.
I was able to achieve something like this in Matlab's Command Window using
datestr(date, 'mm/dd/yyyy')
However, I am unsure where/how to implement this code into my GUI to get it to display the date. Any help would be greatly appreciated. Thanks!

If edit1 is the tag to the editbox, add this to OpeningFcn for the GUI -
set(handles.edit1,'String',cellstr(datestr(date, 'mm/dd/yyyy')));
Thus, today's date would show up in the editbox, once the GUI loads up.

If I understood your question right, you need to use the "String" property of your edit box with the output from datestr(date, 'mm/dd/yyyy').
For instance:
set(handles.EditBox,'String',datestr(date, 'mm/dd/yyyy'));
and that should do it. You can put this line in the Create Function of the edit box, so that when the user will open the GUI the text will already be there.
Hope that's what you meant!

Related

Microsoft Word->Field Code->{TC}

So I am having a problem. This is what I can create on one of my laptop:
On another, when I created something that has {TC} in it, the whole field code disappeared.
For the example above, if on the other computer, both are running Office 2010,
I can input the code to create the table of content from:
{TOC \f \h \z \f 1\t "Heading 1,1,Heading 2,2,Heading 3,3,Title,1}
to
{TC}
The moment I type in TC, the whole {} disappears.
Other field codes work just fine, except for {TC}. So my question is how do I get {TC} to show on my other laptop?
Thank you for your time.
Apparently, I found my answer.
When I searched google for my answer, most sites give this as a solution:
For Word 2010, go to File->Options->Advanced
Under Show document contents: Select "Show field code instead of their values"
This is the equivalent of pressing Alt+F9, which DID NOT solve my problem.
Apparently, the solution to get {TC} to show in your document is in:
go to File->Options->Display
and check to always show HIDDEN TEXT.
I hope this helps someone in the future.
Yeah, the disappearing TC code is annoying at first -- seems like it's broken. Other codes work, but why does that disappear, even if entering manually? Word instantly sets TC code to Hidden, even the field code itself.
To temporarily toggle this visible without permanently changing your display to show Hidden Text, you can use the normal Ctrl-Shift-8, which toggles display of spaces, paragraph marks, tabs, and Hidden Text, on and off. This is a good keyboard shortcut to have in your standard back of tricks anyway. It is frequent in Word that you need to toggle paragraph marks on and off, because paragraph formatting is attached to the Paragraph mark, and when they're hidden, it can be tricky to fix various formatting issues.
The original post was a few years ago, but I fear things have gotten worse since then, not better. I am using Word 365 v2201, which should be up to date. The other day, I wasted hours on trying to resolve this issue with TC field codes.
First I tried entering them using Insert > Quick Parts > Field. Word creates what looks like a field code, but it behaves as normal text. Messing around with the various controls to toggle field display and hidden text etc etc, has absolutely no effect. It is basically a faux field. And of course, it is completely ignored when compiling the TOC.
Next, I tried entering it manually, by using Ctrl + F9 to either create a blank field or convert some existing text into a field. Same result as above.
As with the original post, this seems to afflict only the TC field code. Other codes work fine, including TOC. And if I create a TOC field, then edit the code to TC, it immediately loses its properties as a field. If I then put the O back in, it immediately behaves as a field once again. Unlike in the original post, adjusting the settings for field display and/or hidden text, have no impact.
In the end, the only solution was to create the field using Alt + Shift + o to open the Mark Table of Contents Entry dialog box. And finally, this works!

MATLAB GUI set default values

I am working on a GUIDE in Matlab and I have to constantly change a couple of Edit Text values.
I have realized that if I change the String value of an Edit Text from the property inspector in the .fig file it sticks there when I run the code even if I close Matlab and reopen it, so I suppose that it is stored somewhere. I would like to know if there is a way of changing those 'default' values while running the gui.
I want to add a pushbutton to set the displayed data as default, so it is kept for the next time I run the code.
Thanks very much in advance!
Not sure if there is a more elegant way, but you can do the following as a workaround:
Once the button is clicked
Create a file
Write new default values instead of older ones
At the start of GUI
Open the file
Get the default values
Set the default values on GUI

LibreOffice: Cells with text to date

I have loaded an xlsx file where the original author used Microsoft Office to create the file. In the spreadsheet, there is a column of dates given in format like "DD/MM/YYYY TT:MM:SS", but they are stored as text. Furhteron, "DD/MM/YYYY TT:MM:SS" is not locale default. I cannot find a way to make LibreOffice interpret it as date. Can someone please help me to reach my aim?
Highlight the column of dates. From the menu, select Data -> Text to columns. In the dialog window that pops up, press "OK". That should do it.

Dynamically updating text in Matlab GUI

I think it should be pretty simple what I want to do, basically I have one edit box that displays a value in percentages and another that I want to update to display raw values. I've tried using the following code under the edit1 (percent) callback:
currentKey = str2num(get(gcf,'CurrentKey'));
percent = str2num(get(handles.edit1,'String'));
if ~isnan(currentKey) && ~isnan(percent) && 0<=percent && percent<=100
set(handles.edit2,'String',num2str(2*percent))
end
But it will only update the second edit box if I first click outside of the first one. Anyone have an idea of what I should be doing?
Thanks!
I think this link should help you:
How can I make the text that I enter into an edit text box update dynamically?
Solution:
This enhancement has been incorporated in Release 2011a (R2011a). For previous product releases, read below for any possible workarounds:
This is expected behavior of the Edit Box UICONTROL in MATLAB.
You can try using the 'keypressfcn' to grab the keyboard input. The attached two files demonstrate the ability of real-time text update. As you enter text into the upper edit box, the text will be copied to the edit box beneath it as you enter.
Please download the following two files:
test_keypressfcn.m
test_keypressfcn.fig
Execute the program.
A GUI will appear. Enter text in the upper edit box displayed in the GUI.
Observe the text in the lower editbox is updated dynamically or in real-time as you enter test in the upper edit box.
Please note that this will work only for text that is continuously entered in the editbox. If you type in between words already entered in the editbox the gui will not perform as expected. You will need to implement logic similar to the one in this example to get the behavior that you desire.

Add date to to Crystal Report Text Object

I have a Text Object on my report which is contains some text. What I'd like to do is add a date to the text object that will alaways show the current date. I've tried using a date field, but it is near impossible to line it up correctly.
Any ideas on how to do this? I've been told that there is a way to do this using something like &[], but I can't figure out how.
Thanks!
You can edit the date inline, double click on the text field then select the date text, you can now click on the formatting button on the toolbar and setup the date format.
You can drag any field, including special ones (Print Date for example) into text object - it will line up without problems.