|
|
Home » U++ Library support » U++ Core » Format function conversion specifiers and EditDate widget
Format function conversion specifiers and EditDate widget [message #2077] |
Fri, 31 March 2006 13:31 |
gprentice
Messages: 260 Registered: November 2005 Location: New Zealand
|
Experienced Member |
|
|
Is there a description anywhere of how Format works?
What does the %` do in the code below?
What does ~date1 return?
void Days::Compute()
{
result = IsNull(date1) || IsNull(date2) ? "" :
Format("There is %d day(s) between %` and %`",
abs(Date(~date1) - Date(~date2)), ~date1, ~date2);
}
The code is from the days example on the website. Which Date constructor is used - the copy constructor ???
(Should I be able to find this info in the help?)
Graeme
|
|
|
|
|
Re: Format function conversion specifiers and EditDate widget [message #2081 is a reply to message #2080] |
Fri, 31 March 2006 14:12 |
|
mirek
Messages: 14105 Registered: November 2005
|
Ultimate Member |
|
|
gprentice wrote on Fri, 31 March 2006 07:05 |
Quote: |
Not yet, sorry.
Format works by converting arguments to Value. It is otherwise mostly similar to printf-like formatting, however there are differences. The most important one is that Format is extensible - you can register additional format specifiers and additional types.
|
It's possible I might try to document something as I learn it - really it'd be good if something like the Wiki could be used, to try and get lots of people contributing as they learn things e.g. one Wiki page for each widget, one for each core class, one for each reference app, one for each example.
|
There is a wiki page, feel free to contribute!
Quote: |
Any chance of an answer on the Date constructor question - if squiggle returns Value does Value have user defined conversion to Date and the copy constructor is used? Is Value like a variant - what does it hold for ~date ?
|
Date, as almost any concrete type, is "Value compatible" - it can be seamlessly converted to Value and back. In this particular example:
abs(Date(~date1) - Date(~date2))
~date1 gets a Value (containing a Date) from the date1 widget
Date(...) is Value::operator Date() (in fact, slight irregularity, most other types use constructor T(const Value&) for conversion).
for Date, operator- returns the number of days between two Dates.
Mirek
|
|
|
|
Re: Format function conversion specifiers and EditDate widget [message #2083 is a reply to message #2082] |
Fri, 31 March 2006 14:26 |
|
mirek
Messages: 14105 Registered: November 2005
|
Ultimate Member |
|
|
fudadmin wrote on Fri, 31 March 2006 07:17 |
gprentice wrote on Fri, 31 March 2006 13:05 |
It's possible I might try to document something as I learn it - really it'd be good if something like the Wiki could be used, to try and get lots of people contributing as they learn things e.g. one Wiki page for each widget, one for each core class, one for each reference app, one for each example.
Graeme
|
wikis are rubbish. I don't know any of them which has normal searching capabilities, navigation etc. Why can't you use this forum as a wiki? It has editing. Other communities do that. And you have alerts on updates and discussions visible! What else do you need?
|
Well, in any case, I can always pick interesting documents anywhere and copy them to Topic++ (and that way, also to website).
Mirek
|
|
|
|
|
Goto Forum:
Current Time: Fri Nov 01 00:33:17 CET 2024
Total time taken to generate the page: 0.01695 seconds
|
|
|