You may have to set the switch as a static

Here’s the deal. I have been coding in Clarion for thirty years now and I thought I had seen it all.

I have some code that is using a switch flip/flop variable that I use when I sort the columns of a listbox by doing a mouseleft alert event on ?LIST{PROPLIST:MOUSEDOWNROW} = 0.

If my local variable is set as a simple byte (True/False) the code does not work.

When I switch the variable to a static byte variable it works! Damndest thing!

If somewhere down the line you have a variable that just does not seem to work right, no matter what you do, try setting it to a static. It may work like mine did! The queue of the list box is using colors and has 29 columns so there is a lot of memory in use. It may be that. Mystery of the universe! It works now - move on, nothing to see here…

Wondering if your variable is declared local to the procedure or perhaps a class method?

The variable is a local variable declared in a procedure of a much bigger project (254 source code files). It is 100% hand-coded and classes are not used in this project. Only standard Clarion reference calls are used.

I am sure that fixing this is possible and it is “something” I am doing that is causing this. But, is really worth pursuing since nothing is being hurt by setting the variable to static?

I felt it important to post this so if you ever have an unexplained variable wandering, then try setting it to static to see if the issue goes away. No harm - no fowl, err foul!

If you change a variable to Static, and you want ti to behave “as it did as a local” then you should probably add ,THREAD as well. If you don’t then the variable is not thread safe, so if you have multiple of these windows open you’ll get some really funky behavior.

Simply setting it to Static may introduce really hard to find bugs.

Hi Bruce,

My windows are all modal so zero issues with threading! I also do not allow users into the main exe more than once so I never need to worry about threading issues. Thank Man!