407 views
in Embedded Wizard Studio by

Hello,

is it possible in EW to pass a pointer to a function and modify the value, as you would do it in C/Cpp?

bool GetValue(int ID, int* value)
{
	if(...)
	{
		*value = 123;
		return true;
	}
	else
	{
		return false;
	}
}
res = GetValue(ID, &value);

Best regards

Jonas

1 Answer

0 votes
by
 
Best answer

Hello Jonas,

not directly. What you can do:

Option 1: You can pass an object containing a variable. Within the method you can access and modify the variable. For this application case you implement a new class containing one or more variables. Then you create an instance of the class and pass it in the method invocation. To improve performance you can reuse one and the same object avoiding so its recreation.

Option 2: Another possibility involves property references. In this case the value of interest is stored within a property. When invoking the method you pass a reference to the property. Within the method you can derefence the passed reference and so access and modify the property.

Both approaches are very similar to how pointers work in C. However, the support limits to objects and properties. Pointers pointing directly to variables or arrays are not supported.

I hope it helps you further.

Best regards

Paul Banach

Ask Embedded Wizard

Welcome to the question and answer site for Embedded Wizard users and UI developers.

Ask your question and receive answers from the Embedded Wizard support team or from other members of the community!

Embedded Wizard Website | Privacy Policy | Imprint

...