Multiple conditions

C

crazyrdx

Guest
If a variable OPCODE is "0000 0001" or "0000 0010" or " 0000 0011" or
"0000 0100" , then I wish to perform a certain action.

How can I do this ? Do I need to use if elsif elsif else, or case? Isnt
there an operator which allows me to put all of these in a single if?

thanks
rdx
 
crazyrdx wrote:
If a variable OPCODE is "0000 0001" or "0000 0010" or " 0000 0011" or
"0000 0100" , then I wish to perform a certain action.

How can I do this ? Do I need to use if elsif elsif else, or case? Isnt
there an operator which allows me to put all of these in a single if?
Yes. The "OR" operator.

if
(OPCODE = a) or
(OPCODE = b) or
(OPCODE = c)
then
do_certain_action;
end if;

-- Mike Treseler
 
Mike Treseler wrote:
crazyrdx wrote:

If a variable OPCODE is "0000 0001" or "0000 0010" or " 0000 0011" or
"0000 0100" , then I wish to perform a certain action.

How can I do this ? Do I need to use if elsif elsif else, or case? Isnt
there an operator which allows me to put all of these in a single if?

Yes. The "OR" operator.

if
(OPCODE = a) or
(OPCODE = b) or
(OPCODE = c)
then
do_certain_action;
end if;
It is also possible to use a case statement:

LABEL: case OPCODE is
when a | b | c => do_certain_action;
when d ....
when others ....
end case LABEL;

Regards,
Allan
 

Welcome to EDABoard.com

Sponsor

Back
Top