Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.
|
Forum Index : Microcontroller and PC projects : Multiline IF. Where have I gone wrong?
Author | Message | ||||
GoodToGo! Senior Member Joined: 23/04/2017 Location: AustraliaPosts: 188 |
Howdy all, Long time lurker, first time poster and have finally thrown my hat into the MM ring. Own one of the absolutely brilliant Explore28 jobs and a Silicon Chip MM+ LCD backpack. Been a huge admirer of Geoff's work ever since I built my GPS synchronised clock back in the long long ago. That sucker is still going strong, especially after helping squash the daylight saving bug in it. Anyway, I've been playing around with the MM+ LCD backpack. Great bit of kit but of course there are some minor coding differences between it and a 'normal' LCD backpack. So, the problem. With the Boat computer, there are a couple of lines associated with the touch interrupt side of things that are not applicable to the MM+. So I modified it accordingly, however the following Multiline IF refuses to work. 'Get MM device type if MM.Device$ = "Micromite MkII" then DeviceType = 1 elseif MM.Device$ = "Micromite Plus" then DeviceType = 2 elseif MM.Device$ = "Micromite eXtreme" then DeviceType = 2 Else DeviceType = 1 endif print DeviceType Print MM.Device$ When I run it, the Touchscreen doesn't respond and it produces the following from the two PRINT statements:- However if I recode it to the following:- 'Get MM device type if MM.Device$ = "Micromite MkII" then DeviceType = 1 if MM.Device$ = "Micromite Plus" Then DeviceType = 2 if MM.Device$ = "Micromite eXtreme" then DeviceType = 2 It works as advertised with DeviceType = 2. FYI DeviceType is used to select one of the following statements:- ' this interrupt is used to detect touch on the main screen If DeviceType = 1 then SetPin Peek(Byte Peek(Word &H9D000090) + 23), INTL, TouchDown elseif DeviceType = 2 then gui interrupt TouchDown endif Where have I gone wrong with the Multiline IF statement? Why doesn't it at the very least change DeviceType to '1' as per the last 'ELSE' statement? It's bugging (ha!) me because I can't figure it out. Any thoughts? Cheers, GTG! ...... Don't worry mate, it'll be GoodToGo! |
||||
matherp Guru Joined: 11/12/2012 Location: United KingdomPosts: 8592 |
Try (untested) 'Get MM device type if MM.Device$ = "Micromite MkII" then DeviceType = 1 elseif MM.Device$ = "Micromite Plus" then DeviceType = 2 elseif MM.Device$ = "Micromite eXtreme" then DeviceType = 2 Else DeviceType = 1 endif |
||||
GoodToGo! Senior Member Joined: 23/04/2017 Location: AustraliaPosts: 188 |
Thanks matherp! That sorted it. Can't believe I stared at the screen for hours trying to work it out... especially when you consider I had formatted the second Multiline statement correctly. Ah well, live and learn! Cheers, GTG! ...... Don't worry mate, it'll be GoodToGo! |
||||
WhiteWizzard Guru Joined: 05/04/2013 Location: United KingdomPosts: 2794 |
@GoodToGo Just making you aware that there is also a SELECT CASE command that some people find easier to read. Using the same example as above: SELECT CASE MM.Device$ CASE "Micromite MkII" DeviceType = 1 CASE "Micromite Plus", "Micromite eXtreme" DeviceType = 2 CASE ELSE DeviceType = 1 END SELECT In fact if these are the values you need, it can be shortened further: SELECT CASE MM.Device$ CASE "Micromite Plus", "Micromite eXtreme" DeviceType = 2 CASE ELSE DeviceType = 1 END SELECT WW For everything Micromite visit micromite.org Direct Email: whitewizzard@micromite.o |
||||
GoodToGo! Senior Member Joined: 23/04/2017 Location: AustraliaPosts: 188 |
Hi WW, Thanks for the tip, I like it, it reads well and works a charm. It's going straight to the poolroom. (Gratiuitous "The Castle" reference, hopefully not lost on most people......) Cheers! GTG! ...... Don't worry mate, it'll be GoodToGo! |
||||
Print this page |