649 views
in System Integration by

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
by
 
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 - Archive

Welcome to the Ask Embedded Wizard archive. This community forum served us well for many years, but we've evolved our support approach!

Your resources:

The Embedded Wizard Online Documentation provides comprehensive documentation, tutorials, examples and ready-to-use software packages.

For dedicated assistance, explore our Embedded Wizard Product Support.

You can still browse the valuable discussions from our community history here.

Embedded Wizard Website | Privacy Policy | Imprint

...