about native Code

42 views
asked Dec 20, 2019 in System Integration by Andy

Hi,

I want to change my object icon depend on the device data.

below is my code

var int32 tmp = 0;
native(tmp)
{
  if(current->data.fattrib & AM_DIR)
  {
  	tmp = 1; 
  }
  else
  {
  	tmp = 0;
  }
}
if(tmp == 0)
{itemView.Icon = ImageResource::list;}
else
{itemView.Icon = ImageResource::ship;}

I need to do if else twice.

Is there anyway to do better ?

 

Best Regards

Andy Dong 

1 Answer

0 votes
answered Dec 20, 2019 by Paul Banach
 
Best answer

Hello Andy,

I would implement following code:

var bool tmp = false;

native(tmp)
{
  tmp = ( current->data.fattrib & AM_DIR ) != 0;
}

if ( tmp == false )
  itemView.Icon = ImageResource::list;
else
  itemView.Icon = ImageResource::ship;

Does it help you?

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

...