Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 22:06 08 Jul 2025 Privacy Policy
Jump to

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 : Newie got a few questions

     Page 9 of 25    
Author Message
lew247

Guru

Joined: 23/12/2015
Location: United Kingdom
Posts: 1702
Posted: 05:22am 05 Sep 2016
Copy link to clipboard 
Print this post

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 Kingdom
Posts: 1702
Posted: 07:12am 05 Sep 2016
Copy link to clipboard 
Print this post

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 Kingdom
Posts: 1702
Posted: 08:57am 05 Sep 2016
Copy link to clipboard 
Print this post

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 Zealand
Posts: 711
Posted: 09:27am 05 Sep 2016
Copy link to clipboard 
Print this post

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 Kingdom
Posts: 1702
Posted: 09:29am 05 Sep 2016
Copy link to clipboard 
Print this post

Thanks, I'll give it a try
 
MicroBlocks

Guru

Joined: 12/05/2012
Location: Thailand
Posts: 2209
Posted: 12:30pm 05 Sep 2016
Copy link to clipboard 
Print this post

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 Kingdom
Posts: 1702
Posted: 12:05am 06 Sep 2016
Copy link to clipboard 
Print this post

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: Australia
Posts: 1667
Posted: 12:16am 06 Sep 2016
Copy link to clipboard 
Print this post

Try a Search for 99 just to be sure.

Phil
 
lew247

Guru

Joined: 23/12/2015
Location: United Kingdom
Posts: 1702
Posted: 12:29am 06 Sep 2016
Copy link to clipboard 
Print this post

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 Kingdom
Posts: 2932
Posted: 12:56am 06 Sep 2016
Copy link to clipboard 
Print this post

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: Australia
Posts: 1000
Posted: 01:02am 06 Sep 2016
Copy link to clipboard 
Print this post

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 Kingdom
Posts: 1702
Posted: 01:03am 06 Sep 2016
Copy link to clipboard 
Print this post

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 Kingdom
Posts: 1702
Posted: 01:05am 06 Sep 2016
Copy link to clipboard 
Print this post

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 furtherEdited by lew247 2016-09-07
 
Phil23
Guru

Joined: 27/03/2016
Location: Australia
Posts: 1667
Posted: 01:32am 06 Sep 2016
Copy link to clipboard 
Print this post

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 Kingdom
Posts: 1702
Posted: 01:34am 06 Sep 2016
Copy link to clipboard 
Print this post

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 Kingdom
Posts: 1702
Posted: 01:44am 06 Sep 2016
Copy link to clipboard 
Print this post

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.
Edited by lew247 2016-09-07
 
WhiteWizzard
Guru

Joined: 05/04/2013
Location: United Kingdom
Posts: 2932
Posted: 02:33am 06 Sep 2016
Copy link to clipboard 
Print this post

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 Kingdom
Posts: 1702
Posted: 06:14am 06 Sep 2016
Copy link to clipboard 
Print this post

@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*Edited by lew247 2016-09-07
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 10224
Posted: 06:28am 06 Sep 2016
Copy link to clipboard 
Print this post

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 Kingdom
Posts: 1702
Posted: 06:31am 06 Sep 2016
Copy link to clipboard 
Print this post

Thanks Peter, I'll figure a different way to do what I need
 
     Page 9 of 25    
Print this page
The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025