Hi !
I've used the following If Else if command and ME doesn't report any errors and appears to be working fine also, but after going thru certain post it appears it is not support..
Example:
sub procedure Timer2Int org $0022
if (portB.3=%1) then
LatB.3=%0
else if (PortB.3=%0) then
Latb.3=%1
end if
end if
IFS0.7=%0
end sub
Does ME support if / Else if ..if anyone has used..would appreciate a confirmation.
If / Else if statement
- tihomir.losic
- mikroElektronika team
- Posts: 2138
- Joined: 02 Dec 2009 14:16
- Location: Serbia
- Contact:
Hi,
Please post this question on our Support Desk:
http://www.mikroe.com/en/support/
And provide us with piece of code which demonstrate problem.
Regards,
Losic Tihomir
Please post this question on our Support Desk:
http://www.mikroe.com/en/support/
And provide us with piece of code which demonstrate problem.
Regards,
Losic Tihomir
mikroElektronika [Support team]
Re: If / Else if statement
why not ?nikhil wrote:Hi !
I've used the following If Else if command and ME doesn't report any errors and appears to be working fine also, but after going thru certain post it appears it is not support..
Example:
sub procedure Timer2Int org $0022
if (portB.3=%1) then
LatB.3=%0
else if (PortB.3=%0) then
Latb.3=%1
end if
end if
IFS0.7=%0
end sub
Does ME support if / Else if ..if anyone has used..would appreciate a confirmation.
I dont see any problem with using Else IF (separated keywords).
between ELSE and ENDIF you can use any STATEMENT, and the IF/ENDIF can be used ... so an ELSE can be followed by an IF without problem. You only need to "close" your nested IF with and ENDIF and this is what you are doing. It works.
You should be careful.
Some other basic compilers let you use the ELESIF statement ... (in a single word, without space between ELSE and IF).
writing code like:
Code: Select all
IF cond1 then
...
ELSEIF cond2
...
ELSEIF cond3
...
ELSE
...
ENDIF
in mikroBasic, you should use the more cleaner SELECT CASE statement.
Regards
http://www.pocketmt.com