Whoa! Thank you so much. I keep forgetting to check in with an existing feed and I do not receive follow-up notifications. I may or may not have experienced that problem but I so appreciate you providing a pre-emptive means of avoiding the issue altogether.
I have been busy embodying what you have presented, especially making the dictionary set-up work for me. I finally figured out how to embed the "get the dictionary listing" from the function or equation to the checkbox display page.
I tried playing and researching but to no avail to accomplish the following things. It's like "50 Ways to Leave Your Lover," in that there are many ways to make some routines happen. Can you help me with two variations of your code, please? I would like to have a "Check All: and an :Uncheck All" button on the checkbox page. I would post something to build on if I had even a modicum of success but I am, once again, swimming over my head.
I guess I do have another request or, at least, a question. Is it possible and, if so, how might I bring up two dictionary listings with one checkbox or place two numbers in a single listing? My idea is that, when the dry bulb temperature box is checked and the data displayed, I can associate both the Celsius and Fahrenheit temperatures adjacent to the "Dry Bulb Temp." display page. This would happen with several temperature displays and many other measurements, as well. If this is not practical or even possible, I can easily modify the data request buttons with "Imperial" or "Metric" buttons. I have those associated with the data entry calculator but those are for input selection.
Thank you for reading through all of this. I sometimes walk away from a posting here with a sense of having seen a psychiatrist or emotional-support counselor. It is a feeling of "I don't know how but everything's going to be fine."
You will need a global init for a variable named something like MyCheckboxes, with a create List block with 14 sockets, one per checkbox (last I looked.)
It's easier to add the sockets while they are unpopulated, so you can squeeze them in at the top, because the bottom of the sockets get pushed offscreen.
Add component blocks for your 14 checkboxes to the sockets. The component blocks are the ones at the end of the blocks pallette for each component, without .Anything
See Wordle In A Day for how I do this with Labels and Buttons.
Once you have your global list of checkboxes, you can traverse it in your Button Click event like
for each checkbox in global MyCheckboxes
set Checkbox.Checked of component checkbox to true
Happy hump day (although I haven't held a desk job in a long while;). I am attaching a file and screenshot. I get this error (screenshot) the first time through an operation. If I click outside of the error box, I can continue. If I uncheck and recheck the Wet Bulb box, the error returns. If I continue by selecting ATMO and then "Get Data," the first time, wet bulb is populated with zero. If I return to the checkbox page and select wet bulb again, the error no longer appears. I am befuddled.
The "logical" idea is that one first selects Imperial or Metric, then checks the boxes requested, then clicks "ATMO" and "Get Data." The idea is a top-down sequencing and I will have background colors turning on and off as buttons and checkboxes become available. I do have a couple of other selections besides ATMO but, for simplicity, I wanted to isolate the errors as much as possible.
My question is "how do I keep the error message from showing on my first round through?" Actually, "how do I eliminate the error" is a much better question. I thought I duplicated your logic in the wet bulb sketch you sent but I guess I am missing something(s). As a follow-up, I get the error in the second screenshot if I try to choose out of sequence (ATMO before Imperial or Metric). Is there a way to eliminate this error message or change it to say "Enter Data From the Top Down"? Or something . . .?
I have been doing due diligence here for the last few days but to not much avail. Can you help straighten out my reasoning? Thank you so much.
Wow, I thanked you for your code and, somehow, I totally ignored it.
In the future, I welcome just a simple (I explained that "here") reply to protect your sanity. I probably missed that block of code or deleted it through my lack of GUI skills. Half of my forward progress here is the result of an "Oh, gosh, I totally forgot that" moment. Thank you for responding (again) and for your extreme patience with my ADHDish mind. I will report back when I have successfully incorporated your advice into my script.
OK, that works as advertised;). I replaced the "?" with "Please re-enter your data" and there is no longer the appearance of the app querying me (?).
Could we take this a step further and "discuss" (learn me:) what is happening that causes a first-time entry to come up "NaN" but all subsequent requests are populated with the correct calculations? I have tried changing the sequence of my request but to no apparent avail, and I always bring the BLE device online and connected (displaying live data) before I make a request in my checkboxes.
Do I need to load some dummy data somewhere? I am certain this is not an MIT AB2 restriction . . . I think. BTW, once the numbers populate, they are within a very close tolerance to Internet readings. Dry Bulb = 27.55C, Humidity = 44.57%, DP calculated as 14.97C and WB calculated as 19.21C.
I am attaching two screen shots. The first one just calls up NaN with my answer for the wet bulb and a fat zero for the dewpoint. All subsequent data requests are normal and correct. Is this fixable? Thank you for your knowledge as I pack in whatever will stay.
This is an inevitable result of your data arriving out of sync with each other.
It can be handled in several ways:
By not doing anything in the way of calculation until you have all (numeric) the data, or
By phoning in the calculations when you have incomplete data and returning some kind of Nan asking for patience until the data arrives.
By exercising theatrical showmanship in delaying raising the curtain until all the actors (data) are in place.
I favor the third option.
P.S. On further thought, if the actors are unavailable close the theater and stop selling tickets. The app logic equivalent would be to cycle through all the check boxes and disable and turn off those which would trigger calculations using unavailable or stale data.
You can track freshness of your three inputs (t,h,p) by updating parallel variables t_ms, h_ms, p_ms (initially 0) with Clock1.SystemTime in the BLE arrival events, and check them against current SystemTime minus a second or two.
Hide that logic in a true/false value procedure is_fresh_t, is_fresh_h, is_fresh_p
and use that instead of or in addition to the is_number tests.
I am typing over a fustercluck of gibberish to try to simplify my understanding. On the file I sent to you, after I connect to the ble, I can go to the Basic Outputs Page and see that all of the data has populated the labels. When I check a box and request data for DP or WB, why is it that the information is clearly visible on the output page but not available for the wet bulb or dew point calculations the first time the calculation is run? If this is a timing issue, why are there no further hiccups or glitches until I reboot? At one point, I tried loading the basic output data label information into the calculations (Temperature_F_Label vs Temp_ble) but to no avail.
I apologize for all of the "why, why, why's" but I still feel like I am missing some of the most basic concepts here. I see the data but the app doesn't - weird!
Oops, another "oops!" As my app is getting kind of close to where I want it to be, I am not comfortable posting a more finalized version, as it is probably impossible to get NDAs from everyone who reads this post. I am harvesting local data from WIFI and user data from a data entry pad. It seems that these other data sources will be wiped out every time the Bluetooth Floats event triggers and only ble events would be stored.
It looks like I should choose between calling one of three events for each data source. I.e. instead of "Call Save DryBulbTemp", I should "Call Save BLE_DryBulbTemp" in the Bluetooth floats block, "Call Save NWS_DryBulbTemp" in the Current CDX block, etc by using some "if" statements come output time. Conversely, I could create nine labels (3 for temperature, three for humidity [redundant], and three for air pressure) and call for each label in the appropriate block.
A final possibility that comes to my mind is to create one humdinger of a when/if statement that logically follows from top to bottom and doesn't allow events to trigger until they are reached in the sequence. I would simply incorporate all switch clicks and results in this long block. I think (again;) that this would prevent blocks without data (NaN) from running before their time but your opinion would be highly regarded.
Or maybe I should go back to stocking grocery shelves? Thank you for your patience with me as I attempt to wrap my head around the sequence of operations of my app and gain some commanding knowledge.
I have puzzled over this for a few days so I hope you might push some advice onto me. While you might have me place the ble call procedure blocks in the floats received block, there will be other sources of data. Please critique my thought here. Before, I didn't necessarily get data the first time for the wet bulb or dew point readings because, when the check boxes are checked, they immediately try to run the operations in "when checked." It was my belief that I could place all of my checkboxes into a single procedure that is called, only after all calculations have been performed and labels had been populated.
The program I attached runs in a basic form (from the opening page, backspace into the ble connect page. Once connected, I check all of the boxes. I get the temp, humidity, and pressure in metric or imperial but I get only zeros for the wet bulb and dew point outputs.
Is what I am doing fundamentally wrong and, if so, what may I do to prevent the checkbox functions from being run before the labels have been populated?
If you have addressed this already and I am just not getting it, kindly redirect me to the requested information. Thank you ever so much.
Have you ever seen a TV crime show where the detectives start a murder board, with pieces of evidence posted on a board connected by bits of twine, to help show a pattern or point to a suspect?
I think you need one for your data flow.
I suggest you learn to modularize your code through the use of value procedures and the avoidance of reliance on reading back label.text values into further calculations.
Learn to nest value procedure (function) calls.
Use procedure parameters to expose data flow.
Maxims to follow:
It's always wise
to modularize
If in doubt
rip it out
Also, don't be afraid to move things around if they are happening at the wrong time.
It is obvious to me that I am trying to create chicken salad with my chicken droppings of knowledge and the taste is just not quite right. You mentioned two lines of valuable information that I do not grock at all:
Learn to nest value procedure (function) calls. I have found nothing on the Internet regarding nesting of procedures and
Use procedure parameters to expose data flow. This takes me to my primary question. Is there any source of advance procedure applications? The only thing I found was this: Procedures
but it does not even come close to explaining what you did in the attached MIT file:
I can sort of follow the nomenclature of all of the procedure blocks but I could never assemble something like that from scratch without more thorough documentation than I have found so far. I am trying to understand the advantage of taking a relatively understandable formula like this:
and creating multiple procedural blocks, as I will not be using portions of the formula anywhere else. While I understand that you are a coding professional in this language and you tend to follow the "best practices" that you know (you should see my circuit breaker panels if you want a___-retentive wire art;), are there any advantages to me in making procedures that, for all intents and purposes, disguise the original formula with multiple layers of variables and partial expressions? It seems that procedures are best used when there are equations or short formulas that I would rather not repeat. If I am missing a "bigger picture" here please help me understand any other advantages of procedures. Thanks for the Dragnet idea but the red yarn strung between pushpins of blocks on my wall elicited my cat to advanced degrees of mischief;).
In your work with electronic components, you must have encountered potted components, whose internal workings are covered in plastic and their interface to the rest of whatever system they support is through a smaller number of wires.
A similar concept exists in plumbing. They call such subcomponents manifolds, valves, mixers, and fittings.
Procedures do the same for code. They hide complexity and expose (through their interfaces ) the limitations of their effects on their environment. (It is frowned on to have a procedure converse with global variables on the job, like a servant on the phone in the presence of their master. (I watch too much BBC)).
When using value procedure calls together, it is called piping, like the plumbing analogy, not nesting.