[OpendTect_Developers] Creating detailed error messages in OpendTect
Kristofer Tingdahl
kristofer.tingdahl at dgbes.com
Tue Dec 15 13:59:10 CET 2009
Hi all,
On Mon, Dec 14, 2009 at 9:56 PM, Tracy Stark <tstark3 at attglobal.net> wrote:
> Thanks for this info. Is there any limit on how much more you can add?
> Can you add float or integers? Do they have to be printed to a string
> first?
>
No, there is no limit how much can be added, but don't put the user in
trouble by filling his screen.
You can add integers, floats and whatever you like, printed to a string. You
can use the old sprintf function to compose a string, but it's more
convenient to use our BufferString. Say you want to compose the string
"In-line AAAA uses BBBB kbytes". This can be done by the following code:
#include "bufstring.h"
#include "keystr.h"
#include "uimsg.h"
....
int inline_number = 500;
float nrkbytes = 10.4;
BufferString message = "In-line ";
message += inline_number;
message += " uses ";
message += nrkbytes;
message += " kbytes.";
FileMultiString error = "Out of memory";
error += message;
uiMSG().errorWithDetail( error );
The error dialog will now show "Out of memory", and the details section will
say: "In-line 500 uses 10.4 kbytes".
The benefit of the BufferString compared to sprintf is that in only
allocates the amount of memory needed, while you have to know on forehand
how much memory you might need with sprintf.
Happy coding,
Kristofer Tingdahl
--
Kristofer Tingdahl, Ph. D.
Executive Vice President - Americas
dGB Earth Sciences
+1 281 240 3939
http://www.dgbes.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.opendtect.org/pipermail/developers/attachments/20091215/6a9dcc11/attachment.html>
More information about the Developers
mailing list