MX_STRING

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 5.
To post in this forum you must have a registered copy of Flowcode 5 or higher.

Moderator: Benj

Post Reply
Sefi
Posts: 56
Joined: Mon Sep 29, 2008 10:26 am
Has thanked: 9 times
Been thanked: 14 times

MX_STRING

Post by Sefi »

When using datatype MX_STRING in a custom function, Flowcode adds an additional parameter in the function declaration immediately after this variable. Why is this?

As an example:
In a custom component, I have a function with the following declaration:

Code: Select all

void TFT_Do_something( MX_STRING Text)
{
/*Macro_TFT_Do_Something_Start*/


/*Macro_TFT_Do_Something_End*/
}
In the Macro function declarations in the C code the following appears:

Code: Select all

void FCD_Custom20_TFT_Do_Something(MX_STRING Text, MX_UINT8 MSZ_Text);
What is this second variable that appears in the function declaration?

Also when using the component in flowcode it works fine and the fields window does not show this variable, however if you look at the customize component code window and the component macros prototype this additional field appears.

Interestingly if you use unsigned char* which is the definition of MX_STRING, the second parameter is not added in the generated code. :-(

any ideas anyone?

many thanks
Sefi

User avatar
JonnyW
Posts: 1230
Joined: Fri Oct 29, 2010 9:13 am
Location: Matrix Multimedia Ltd
Has thanked: 63 times
Been thanked: 290 times
Contact:

Re: MX_STRING

Post by JonnyW »

Hello.

The MX_STRING is an array of characters. In order for Flowcode to detect if you overflow an array and behave 'safely', it also passes in the size of the original string.

For example, if you create a string of 23 characters and pass this to the component, the MSZ_Text will equal 23.

The code parser does not know what base type (char*) MX_STRING actually is, so it is only looking for this data type. This means it does not pick up on char* and add the extra parameter.

I hope this makes things clearer.

Jonny

Sefi
Posts: 56
Joined: Mon Sep 29, 2008 10:26 am
Has thanked: 9 times
Been thanked: 14 times

Re: MX_STRING

Post by Sefi »

Jonny,

Thank you for your quick response. Much clearer now. I thought I was going mad :-)

many thanks
Sefi

Post Reply