select case function not operating in this situation

Beta Testing discussion on mikroBasic PRO for PIC.
Post Reply
Author
Message
chipbreaker2
Posts: 31
Joined: 15 Apr 2010 16:56

select case function not operating in this situation

#1 Post by chipbreaker2 » 01 Oct 2010 17:17

Hi , I have been trying to get the select case routine to work in the following manner;

Code: Select all

  z=0
    z =3    ' this is only a test temporary debug-setting of z
  select case z
  case 1
   lcd_out(2,1,"Volts")
  case 2  
  lcd_out(2,1,"Ampere")
  case 3 
   lcd_out(2,1,"Ohms")
  case 4 
   lcd_out(2,1,"watts")
  case else   lcd_out(2,1,"fail")
  end select
  /code] 
z has set as a byte, the only case section that functions is the "else" case and fail is displayed on the LCD.I have experimented with values of z, and originally had used tmr0 to provide the value. No attempts have succeeded as yet. I get the impression that the conflict is the call to the  LCD function, Anyone  else found this ,any ideas please?
Most know what they know, I know what I don't know! (Albert Einstein)
This is good to remember when one is confronted by a one upper know it all!
It is usually those that don't know that respond unhelpfully to those that ask for help!

p.erasmus
Posts: 3391
Joined: 05 Mar 2009 10:28

Re: select case function not operating in this situation

#2 Post by p.erasmus » 01 Oct 2010 17:47

This is not a Beta problem you should post in the Basic Forum
not in the Beta Forum,as the Beta period is past ,if you are still using the Beta
version you should upgarde to the V4.1 release compiler
P.Erasmus
Saratov,Russia
--------------------------------------------------------------

p.erasmus
Posts: 3391
Joined: 05 Mar 2009 10:28

Re: select case function not operating in this situation

#3 Post by p.erasmus » 01 Oct 2010 18:09

it seems that the compiler is using the letter Z for something
however using normal variable names as specified by the
Basic language rules the select case works perfectly
see below the debugger stoped at the case 3

Code: Select all

  dim myvar as byte

'*************************************************************************
main:

while(True)
   nop
   myvar = 3
   nop
 select case myvar
  case 1
    nop
  case 2
    nop
  case  3
    nop
  case 4
    nop
 end select
wend
end.
This also workes

Code: Select all

  dim c as byte

'*************************************************************************
main:

while(True)
   nop
   c = 3
   nop
 select case c
  case 1
    nop
  case 2
    nop
  case  3
    nop
  case 4
    nop
 end select
wend
end.
Attachments
3.png
3.png (12.3 KiB) Viewed 3741 times
P.Erasmus
Saratov,Russia
--------------------------------------------------------------

chipbreaker2
Posts: 31
Joined: 15 Apr 2010 16:56

Re: select case function not operating in this situation

#4 Post by chipbreaker2 » 01 Oct 2010 18:27

Thank you, P.Erasmus, that must be the case, I will try that out. I mention however that prior to testing with the Z I used tmr0 as the value, this also didn't function. Thank you also for taking the time to prove it.

IE: Lcd_write (2,1,tmr0). Is tmr0 not allowed?
Regards Brian.
P.S. Purely a personal comment. :D
I placed this question here in case it was a problem that could or should have been found in the Beta version.
I only post the problems I find in the interest of Mikroe finding all or any of the bugs, as i 100% happy with the product. Sometimes I may query some aspect that turns out to be my oversight, I dont like to feel a foolish when I do something dumb, however even tho the problem I mention may be my failure, the fact that it has been mentioned may help someone else who has made similar mistakes. I think we all learn a lot from these forums!
Most know what they know, I know what I don't know! (Albert Einstein)
This is good to remember when one is confronted by a one upper know it all!
It is usually those that don't know that respond unhelpfully to those that ask for help!

chipbreaker2
Posts: 31
Joined: 15 Apr 2010 16:56

Re: select case function not operating in this situation

#5 Post by chipbreaker2 » 01 Oct 2010 18:50

Hi P.Erasmus again reference to the select case problem.
I just tested your example with the 'lcd_out' function and regardless of which variable I use it fails. I think the problem lies not with the select case and the variable type that you showed but when the select is referred to the 'lcd_out' function!
vis:

Code: Select all

    item =3
  select case item
  case 1
   lcd_out(2,1,txt1)
  case 2  
  lcd_out(2,1,txt2)
  case 3 
   lcd_out(2,1,txt3)
  case 4 
   lcd_out(2,1,txt4)
  case else   lcd_out(2,1,"fail")
  end select
/code]
Always it falls through to the else and returns "fail"

By the way I forgot to mention, yes this is the latest non beta version.
Regards Brian
Most know what they know, I know what I don't know! (Albert Einstein)
This is good to remember when one is confronted by a one upper know it all!
It is usually those that don't know that respond unhelpfully to those that ask for help!

p.erasmus
Posts: 3391
Joined: 05 Mar 2009 10:28

Re: select case function not operating in this situation

#6 Post by p.erasmus » 01 Oct 2010 19:03

I just run your code with me it is working !!
Here you see the LCD code execute
Yes and you are correct we all learn a great deal here
in the Forum :D
Attachments
5.png
5.png (7.18 KiB) Viewed 3736 times
Here you see the LCD function executed
Here you see the LCD function executed
4.png (19.91 KiB) Viewed 3736 times
P.Erasmus
Saratov,Russia
--------------------------------------------------------------

chipbreaker2
Posts: 31
Joined: 15 Apr 2010 16:56

Re: select case function not operating in this situation

#7 Post by chipbreaker2 » 01 Oct 2010 19:11

OK P.Erasmus, thanks for your assistance, I guess I must re-install my compiler as I still cant get it to operate correctly.
Have a good day, Regards Brian :D
Most know what they know, I know what I don't know! (Albert Einstein)
This is good to remember when one is confronted by a one upper know it all!
It is usually those that don't know that respond unhelpfully to those that ask for help!

p.erasmus
Posts: 3391
Joined: 05 Mar 2009 10:28

Re: select case function not operating in this situation

#8 Post by p.erasmus » 01 Oct 2010 20:41

you are welcome :D
P.Erasmus
Saratov,Russia
--------------------------------------------------------------

Post Reply

Return to “mikroBasic PRO for PIC Beta Testing”