Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
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 Go to next message
gprentice is currently offline  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 #2079 is a reply to message #2077] Fri, 31 March 2006 13:48 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
gprentice wrote on Fri, 31 March 2006 06:31


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





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.

Mirek
Re: Format function conversion specifiers and EditDate widget [message #2080 is a reply to message #2079] Fri, 31 March 2006 14:05 Go to previous messageGo to next message
gprentice is currently offline  gprentice
Messages: 260
Registered: November 2005
Location: New Zealand
Experienced Member

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.

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 ?

Graeme
Re: Format function conversion specifiers and EditDate widget [message #2081 is a reply to message #2080] Fri, 31 March 2006 14:12 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
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 #2082 is a reply to message #2080] Fri, 31 March 2006 14:17 Go to previous messageGo to next message
fudadmin is currently offline  fudadmin
Messages: 1321
Registered: November 2005
Location: Kaunas, Lithuania
Ultimate Contributor
Administrator
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?
Re: Format function conversion specifiers and EditDate widget [message #2083 is a reply to message #2082] Fri, 31 March 2006 14:26 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
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
Re: Format function conversion specifiers and EditDate widget [message #2084 is a reply to message #2082] Fri, 31 March 2006 14:35 Go to previous messageGo to next message
gprentice is currently offline  gprentice
Messages: 260
Registered: November 2005
Location: New Zealand
Experienced Member
fudadmin wrote on Sat, 01 April 2006 00: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?



Sounds good to me. As far as I can see, plenty of people are learning things (especially from Mirek) but nobody's adding what they learn to the documentation. However I don't want to be the instigator of adding a bunch of topics/ sections to the forum that nobody's going to use. It might be hard to persuade people to write up what they learn ...

Can everyone edit the same post - or would you end up with a string of posts all on one particular widget or class or topic?

Graeme
Re: Format function conversion specifiers and EditDate widget [message #2087 is a reply to message #2084] Fri, 31 March 2006 15:24 Go to previous message
fudadmin is currently offline  fudadmin
Messages: 1321
Registered: November 2005
Location: Kaunas, Lithuania
Ultimate Contributor
Administrator
gprentice wrote on Fri, 31 March 2006 13:35



1. ... but nobody's adding what they learn to the documentation.

2. ...However I don't want to be the instigator of adding a bunch of topics/ sections to the forum that nobody's going to use.

3. It might be hard to persuade people to write up what they learn ...

4. Can everyone edit the same post - or would you end up with a string of posts all on one particular widget or class or topic?

Graeme



1a) Forums are some kind of source for/of the documentation.
Currently, forums have far better searching capabilities than Topic++.

1b) AFAIK, Mirek is adding constantly from forums to the website.

1c) I've been adding my commented examples to "Extra libraries..." category
1d) and trying to ask questions even I can find the answers myself (but usually Mirek is lightning fast... Smile)

----
2a) We can use vote for each topic! Later then can be deleted or archived. Also, there are counters how many times each topic has been opened. (You can't have that with wikis... Smile )

2b) How do you know in advance that something is not useful if you haven't tried? (applies to conservative U++ "not users", too Smile )
----
3. Best persuading is persuading by example...
----
4a) It is possible to let users edit each others posts but then you lose the possibility to compare and get fighting chances "I want this and you deleted!!!" If you study wikipedia more deeply you can see how many topics are locked and what's going on behind the scenes...

4b)IMHO, you will never end with "long string" just because of
3- "It might be hard to persuade people to write up what they learn ..." Smile

So, just do! Lot of things in the world could have been done if people wouldn't base their decisions on imaginable failure... Smile
Previous Topic: Hashes in U++
Next Topic: What is lock for in MenuBar etc. classes? -[SOLVED]-recursive call
Goto Forum:
  


Current Time: Wed Apr 17 00:07:27 CEST 2024

Total time taken to generate the page: 0.02306 seconds