Strange Exception With Exclamation Point
This is a strange one. This will be very technical and perhaps mainly directed at ProFantasy and any XP developers out there.
I found a veerrry strange issue with the XP SDK. In the XP tutorials and the XP Visual Studio template from the ProFantasy web site, there's code for an About box. This has always worked very well right out of the box. Of course, one should modify it to reflect the functionality of the XP. I did that, and came across this issue that I had a hard time pinpointing. This seems to be directly related to CC3 XP and not C++ in general.
This code works:
FORMST(Message, "Blah blah\n\n"
"Hello."
)
FormSt(&Message, RSC(FD_MsgBox));
CmdEnd();
Now, if I simply add an exclamation point into the string, it throws a memory access exception in FormSt:
FORMST(Message, "Blah blah!\n\n"
"Hello."
)
This took me a while to find. This doesn't seem like a C++ issue. I've used many exclamation points in strings over in my life, and I never saw anything like this. The include files in the SDK don't give much information on the implementation of the FormSt function, so I'm stumped.
Why would one specific character cause this? Any thoughts are welcome!
Comments
In C, the format specifier string for printf is %, which means that anytime a percent character appears in a string the next character is treated as a modifier for the elements to be output. For example, using printf("%s - %d", "a string", 2) will print "a string - 2".
In FastCAD, printing is done using the string formatting routine FormSt and an edit packet. The exclamation point is used for term expansion and identifies which edit packet to use at that position. An example from the SameAs command:
This sample creates a command with 4 parameters and passes it to the FastCAD command line processor.
Boom. Great. Thank you.