Assert and the optional Message

Mike Parker aldacron at gmail.com
Fri Mar 9 03:37:21 PST 2012


On 3/9/2012 4:42 PM, Chris Pons wrote:
> I am new to D and have been playing around with Assert. I figured that
> using a message with assert would be very helpful, but unfortunately
> when the message is printed to the console, the console closes and my
> program ends.
>
> Is there any way to get a more permanent message?
>
> I've tried adding system("PAUSE") and it doesn't have any effect.
>
> Is there any way I could have the assert function print the message to a
> file?
>
> I'm using VS2010 and Visual D if that is of any importance.
>

In this case, you can just open up a command window, navigate to your 
executable directory, and execute the app manually from the command 
line. Then you don't have to worry about it closing.

Of course, this doesn't work if you are using the default output 
directories for your executable, but you have resources in the working 
directory. When I use VisualD, I generally configure my executables to 
all go a single bin directory (foo.exe for release, foo_dbg.exe for 
Debug). Then I keep a command window open in the background. That way, 
if I need to run from the command line, it's easy to do so without any 
copying around.


More information about the Digitalmars-d-learn mailing list