Jump to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Plug-In Development: C++ FM Text to Char?

Featured Replies

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

  • 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

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.