September 1, 200421 yr Hi All, I haven't used C++ for a while. I'm currently looking at writing my own plug-in for FileMaker 7, but I'm having difficulties converting parameters (passed to a function) into type const char*. Essentially, I'm trying to do this: const char* MyChar = dataVect.AtAsText(0); I've tried using static_cast, creating local fmx::TextAutoPtr variables as intermediaries (variable->Append(...)), etc, but have had no luck after hours of trying. In addition, it's unfortunate that there is a lack of documentation from Filemaker as to what the methods for their classes actually do. The fact that it's been over 10 years since I last used C++ is probably what makes this frustrating, tho! :-) Any help is greatly appreciated. Thanks! Cobra
September 2, 200421 yr Author Hi Everyone, Well, I've answered my own question and I thought I'd share (also, I'm hoping that there's a more efficient way to do this). The only thing this won't do properly is handle single and double quote characters (but I expect to work around this pretty quickly now). EDIT: Oops! I was passing smart (curly) quotes. The code below handles single and double quotes without problems. Here's the code (please excuse the formatting): fmx::TextAutoPtr MyParameterText; //A pointer to the parameter's text. fmx::ushort UnicodeCharStr[100]; //A temporary holder for one unicode character fmx::ushort UnicodeCharStr2; //Used to get the first position of the unicode character, //which is the equivalent of the ASCII integer // version (I think!). fmx::ulong ParamSize; //The number of characters in the parameter fmx::ulong x; //A counter string MyText; //The resultant string of characters //Set the parameter text to the text variable MyParameterText->AppendText( dataVect.AtAsText(0), 0, static_cast<fmx::ulong>(-1) ); //Get the number of characters in the text ParamSize = MyParameterText->GetSize(); //Initialize the counter x=0; //Loop through the characters in the text while (x < ParamSize) { //Set the integer array to the unicode expression of one character in the text MyParameterText->GetUnicode(UnicodeCharStr, x, 1); //set the integer to the first position in the array UnicodeCharStr2 = UnicodeCharStr[0]; //Add the integer as a character to the resultant string. MyText = MyText + (char)UnicodeCharStr2; //Iterate the counter x++; } The resultant string, MyText, can easily be converted to const char through: MyText.c_str(); If someone has a quick work-around for getting the single and double quotes out, please do share (EDIT: Problem solved, see above). Also, it's obviously less efficient to do this character by character...is there any way to convert the text to a char string in one go? Note that this method is pretty much what the Troi Example plug-in code does. Hope this helps someone! Cobra
Create an account or sign in to comment