![]() |
Forum Index : Microcontroller and PC projects : Newie got a few questions
![]() ![]() ![]() ![]() |
|||||
Author | Message | ||||
lew247![]() Guru ![]() Joined: 23/12/2015 Location: United KingdomPosts: 1702 |
I've said it before and I'll say it again I'm an idiot, such a small thing, that I "should" have known and spotted myself. Sorry everyone. and Thanks ![]() MikeO the reason I haven't used your function, is I was given 2 at the same time and both do almost the exact same thing, it was simply a matter of picking one and it wasn't anything against yours that I didn't use it, Jean's one makes certain the array is empty when it is called. Your possibly does or could do it as easily but it was just simpler to use this one. Thanks though Lewis |
||||
lew247![]() Guru ![]() Joined: 23/12/2015 Location: United KingdomPosts: 1702 |
Is it possible to check if a field array string = one of a number of strings, and then if it does not = ANY of the named strings bin the array and start again with the next serial input? There are about 10 values for the array$ to check and if none of the values match then ignore the array |
||||
lew247![]() Guru ![]() Joined: 23/12/2015 Location: United KingdomPosts: 1702 |
To clarify, I need to check if FieldArray$(2) = "01d" OR "01n" OR "02d" OR "02n" and so on (each number = an icon name) and if FieldArray$(2) does NOT = any of the above then ignore and carry on with the rest of the program hope that made sense |
||||
jman![]() Guru ![]() Joined: 12/06/2011 Location: New ZealandPosts: 711 |
Hi Try this Select Case FieldArray$(2) Case "01d" Do some stuff Case "01n" Do some stuff" Case "02d" Do some stuff Case "02n" Do some stuff Case Else Do some other stuff End Select Regards Jman |
||||
lew247![]() Guru ![]() Joined: 23/12/2015 Location: United KingdomPosts: 1702 |
Thanks, I'll give it a try |
||||
MicroBlocks![]() Guru ![]() Joined: 12/05/2012 Location: ThailandPosts: 2209 |
This is the most compact form. Just add every item that you want to test for in the first parameter of the instr function. Here i used a few as an example. [code] If instr(",01d,01n,02d,02n,", "," + FieldArray$(2) + "," > 0 then 'Pattern found Icon$ = FieldArray$(2) + ".ppm" else 'Pattern not found endif [/code] Microblocks. Build with logic. |
||||
lew247![]() Guru ![]() Joined: 23/12/2015 Location: United KingdomPosts: 1702 |
Guess what - back again! [quote][49] GUI SWITCH sw1, "Weather|Forecast", 270, 0, 280, 30, RGB(white),RGB(brown) Error: GUI reference number #99 is in use[/quote] Any ideas? I'm trying to display a switch on top of a .ppm picture The relevant sections of code are and "99" isn't used anywhere else in the code [code]Const sw1 = 99 GUI SWITCH sw1, "Weather|Forecast", 270, 0, 280, 30, RGB(white),RGB(brown) CtrlVal(sw1) = 1[/code] |
||||
Phil23 Guru ![]() Joined: 27/03/2016 Location: AustraliaPosts: 1667 |
Try a Search for 99 just to be sure. Phil |
||||
lew247![]() Guru ![]() Joined: 23/12/2015 Location: United KingdomPosts: 1702 |
I did that, it appears nowhere else in the code. I actually changed it to 99 because of this problem, it was #1 at first I just checked the whole code in case I was calling it somewhere else in the code but I'm not |
||||
WhiteWizzard Guru ![]() Joined: 05/04/2013 Location: United KingdomPosts: 2932 |
Do a search on SW1 as you may be using it to define more than one GUI control ![]() |
||||
disco4now![]() Guru ![]() Joined: 18/12/2014 Location: AustraliaPosts: 1000 |
Are you writing the control more than once? I guess you have to write it again after a change of background. Are you using CLS or GUI DELETE to get ready to write it again. Is it intermittent or a hard on fault? Latest F4 Latest H7 FotS |
||||
lew247![]() Guru ![]() Joined: 23/12/2015 Location: United KingdomPosts: 1702 |
For once I'm ahead of you Phil There is only one GUI control in the whole program, the switch which I'm "going to" use to switch display pictures and what's shown on screen |
||||
lew247![]() Guru ![]() Joined: 23/12/2015 Location: United KingdomPosts: 1702 |
umm good question I'm only writing the switch once and then using sub's to change the display picture depending on the switch value I wonder if I have to write the switch each time? At the moment I'm writing it before the picture change routines EDIT: Just changed the code to check where the error is occuring, it's definitely occuring on the command to display the switch, the program goes no further |
||||
Phil23 Guru ![]() Joined: 27/03/2016 Location: AustraliaPosts: 1667 |
Is the Switch in a loop or a Sub that's called more than once? That would probably effectively be trying to define it more than once. |
||||
lew247![]() Guru ![]() Joined: 23/12/2015 Location: United KingdomPosts: 1702 |
Nope The control (switch) is called at the start of the program, it is never told to draw the switch again Once the screen is pressed the display does a cls then loads a new background picture BUT the program never gets far enough to draw anything |
||||
lew247![]() Guru ![]() Joined: 23/12/2015 Location: United KingdomPosts: 1702 |
Basically it does this CLS open the com port draw the clock hand centre circles sets the time functions display the switch check the serial port If the port has valid data extract arrays from the port display the relevant data in the right position SUB if switch is pressed cls display a picture do stuff end sub SUB if switch is pressed again cls display a different picture do stuff end sub It only gets as far as display the switch and crashes for some reason I cannot understand, the gui number for the switch is definitely not used elsewhere EDT: The switch is drawn on the screen and can be touched and it changes to show it's been touched. |
||||
WhiteWizzard Guru ![]() Joined: 05/04/2013 Location: United KingdomPosts: 2932 |
Email me a 'snippet' of COMPLETE test code that does not work for you and I will take a look and run it on an E100 here. ![]() |
||||
lew247![]() Guru ![]() Joined: 23/12/2015 Location: United KingdomPosts: 1702 |
@Matherp The gui switch routing works fine on it's own, but when I try and incorporate it with the clock routine it brings up that error. Is it possible that's somehow stopping the gui control working? I know it's highly unlikely but thought it best to ask* |
||||
matherp Guru ![]() Joined: 11/12/2012 Location: United KingdomPosts: 10224 |
As others have found and documented it is very difficult and in some cases impossible to combine GUI and non-GUI drawing commands successfully. This is even the case for simple things like using the TEXT command with GUI commands in the same program. My routines for things like clock hands do all sorts of things that are likely to conflict with GUI commands. If you are using things like the clock and the fast picture display routines then you will almost certainly have to code switches using the Basic drawing commands and stay away from GUI completely |
||||
lew247![]() Guru ![]() Joined: 23/12/2015 Location: United KingdomPosts: 1702 |
Thanks Peter, I'll figure a different way to do what I need |
||||
![]() ![]() ![]() ![]() |
![]() |
![]() |
The Back Shed's forum code is written, and hosted, in Australia. | © JAQ Software 2025 |