I've already solved the issue which I will describe here but I just wonder why I have to do it as it is done now.
I am working on my Excel reader and changed from .Net Core to Vulcan dialect so I can create a DBF from the Excel sheet. On the WPF form I added a checkbox with name cbisheader and if checked the program knows that the first row in the Excel contains the headers.
So I used:
This is the VO/Vulcan way but it doesn't work. I get:
Error XS0079 The event 'System.Windows.Controls.Primitives.ToggleButton.Checked' can only appear on the left hand side of += or -=
After some search (somebody wrote "Checked here is an event, not a bool, that happens when it is checked. You need a different property - presumably IsChecked.") I changed it to:
Error XS0266 Cannot implicitly convert type 'logic?' to 'logic'. An explicit conversion exists (are you missing a cast?)
Below what finally worked. But it doesn't make sense to me. I would expect the above should work, or this one but with a double =.
This is because apparently IsChecked is not of normal LOGIC type, but it returns a special type, a nullable logic. This is different in the sense it provides 3 states, yes, no and "don't know" (when the value is NULL).
In order to use such a type, you'd normally need to check first:
IF cbisheader:IsChecked:HasValue // returns false if it is NULL
and only if the above returns TRUE, then you can be sure that the var does hold a LOGIC value (and not NULL), and you can access this value with
IF cbisheader:IsChecked:Value // true or false
or with the (cast) that you used before.
The reason behind introducing Nullable types, is to provide this "do not know" value to common types, likes ints. So, for example, a nullable int can have all the values a normal int has, but it can also hold NULL, which may mean that the value has not be assigned yet, when reading it from a database the contents where corrupted, things like that. With a normal int, we would need to use for example by convention a value of -1 to denote "invalid vale", but this causes all sorts of problems, thus the introduction of nullable types in .Net.
Now, why on earth should a CheckBox have a "don't know" value in addition to checked and unchecked, I have no idea, you'd need to ask the people who designed WPF about this
Thanks for the lesson. I can imagine the "don't know" - it is not uncommon, given the privacy rules, to see questions like Male/Female expanded with "don't want to say". So the nullable logic is the logic? I understand.
Yeah - and if the unknown moron who coined the "null" instead of "unknown", or better, "not assigned", had known better, many, many misconceptions could have been avoided...
Probably the same guy who thought it was a good idea to make indexes zero based .
Well a decimal system means 10 digits, not 11 like the way the average person think...
0...9 = 10 Numbers,
1...10 = 10 Numbers // Ask anybody with this mindset and they will tell you, oh yes 0 is also a number. Therefore 1...10 means actually 0...10 = 11 Numbers, it is actually the only Number system that uses this concept, 0...1 = 2 Numbers, 0...7 = 8 Numbers, 0..15 = 16 Numbers, 0...127 = 128 Numbers, 0..255 = 256 Numbers...
Even, how many fingers can you possibly see, is not 10 answers, it is 11... We not using a Decimal system actually, we on a Number11 system... No sorry it is actually Number21... if showing fingers palm forward or backward is added, or if palm forward means "+", we have -10...9, again 21 possibilities...
I rest my case with /az as X# switch...
George, South Africa