I have a quadratic equation struct, and I’d like to make it look nicer in the visual studio 2008 debugger. Here’s the struct:
struct QuadraticEquation
{
float squareCoefficent; float linearCoefficent; float yIntersection;
}
I’d like it to appear as a properly formatted equation in the debugger:
3.0x^2 - 1.3x + 6.5
Here’s the autoexp.dat preview script:
QuadraticEquation{
preview
(
#if($c.squareCoefficent != 0.0f)
(
#($c.squareCoefficent, "x^2")
)
#if($c.linearCoefficent < 0.0f)
(
#(" - ", -$c.linearCoefficent, "x")
)
#elif($c.linearCoefficent > 0.0f)
(
#(" + ", $c.linearCoefficent, "x")
)
#if($c.yIntersection < 0.0f)
(
#(" - ", -$c.yIntersection)
)
#elif($c.yIntersection > 0.0f)
(
#(" + ", $c.yIntersection)
)
)
}
Pretty straight forward. But when I run the code, I get the following error message:
ERROR! Autoexp.dat:line(286) for 'QuadraticEquation': Failed to match ')' for preview/children rule
The line number corresponds to the second #if branch, that starts #if($c.linearCoefficent < 0.0f)...
If I remove everything except the square coefficent branch, it doesn’t error. If this means that I can’t have sequential #if blocks, how else could I do what I want here – without dropping into a dll?
I think you have to use nested
#if‘s to achieve something like this. Check howstd::complex<*>is done in the defaultautoexp.dat.This will take a lot of typing to cover all possible combinations. Do you really need that? Maybe displaying it simply as a struct is good enough for practical purposes.