Make this line of code more efficient?

 
Hello,

I really feel I must be missing something. I want to test if an integer is one of several values. Here is what I'm doing now:

.....
OrderSelect(myTicket);
myOrderType=OrderType();
if(myOrderType==OP_BUYLIMIT || myOrderType==OP_BUYSTOP 
	|| myOrderType==OP_SELLLIMIT || myOrderType==OP_SELLSTOP);
     {
     isPendingOrder=true;
     }
....



I'm looking for something like we would have in a dBase type language like

INLIST(myTicket,OP_BUYLIMIT,OP_BUYSTOP,OP_SELLLIMIT,OP_SELLSTOP)




Can't seem to find anything better than a whole bunch of ||'s. Curious if it is there. Anyone care to educate me?

Thanks!!

-Christian

 
You may use the "Switch" operator, or just test the value of myOrderType :

isPendingOrder=false;
if(myOrderType >= 2) isPendingOrder=true;

or:

isPendingOrder=(myOrderType >= 2) ;
 
You may use the "Switch" operator, or just test the value of myOrderType :

isPendingOrder=false;
if(myOrderType >= 2) isPendingOrder=true;

or:

isPendingOrder=(myOrderType >= 2) ;


I've had other needs for something like this so I thought I'd ask. As for the pendingOrder=true, good solution, I just get paranoid about them coming out with a new order type someday and code breaking.

Thanks so much for taking the time!

-Christian
 
if(myOrderType==OP_BUYLIMIT || myOrderType==OP_BUYSTOP 
	|| myOrderType==OP_SELLLIMIT || myOrderType==OP_SELLSTOP);


I use same condition for mine but without semicolon for if() statement.
Reason: