That doesn’t qualify as a D’oh on your part. Format has been part of REALBasic for as long as its been around. So much is different in IOS
look like hopes of being able to reuse large chunks of even non-UI code are now unrealistic…
I’ve also just learned that Val is gone as well. You now use NumericType.FromText(sometextValue)
But don’t try to read the text from a TextField because you’ll get an UnsupportedFormat exception. Apparently, it must be a two step process - assign the Textfield’s Text to a “Text” variable and the Double.FromText that variable. Still trying to get that one sorted.
All I need for this simple tool to do is to take some large numbers, get a multiplier value from the user, run some simple multiplication and addition on the numbers and display the results in 3 labels.
I’m also having a blast with controls jumping all over the place while I’m trying to get things laid out, but that’s a topic for a new conversation.
[quote=150720:@Tim Jones]But don’t try to read the text from a TextField because you’ll get an UnsupportedFormat exception. Apparently, it must be a two step process - assign the Textfield’s Text to a “Text” variable and the Double.FromText that variable. Still trying to get that one sorted.
I’m not sure why you’d be getting the exception. Could you post some sample code?
Then maybe it should return “NaN” or 0 instead of an error?
What other changes versus Val does this bring? I constantly converted text to numbers with Val where the text would be something like “1200KB” or “12345MiB”. Val knew to ignore the textual part and gave me values of 1200 and 12345.
Not doing so is a great opportunity for silently doing something really wrong.
VAL would gladly give you 0 for val"(foo") and your calculation then proceeded to turn out erroneous results.
We have a number of bug reports about how Xojo can’t do proper math for this sort of reason.
One of the new framework design principles is to not fail silently, and returning something indistinguishable from a potentially proper value (like 0) should not represent an error. Trying to convert a non-number to a number and sometimes getting it right but sometimes getting it wrong- and never saying anything- can be a recipe for disaster.
A variation of a real world example I was helping someone with: just glance at “abc12345abc”, “abc12345”, “12345abc”- what do you think Val would return for those? Most people get it wrong particularly if they haven’t used it a lot. It’s not a good thing.
The perspective taken is that the Xojo developer is in a much better place of understanding to know when/how their particular input should be sanitized or transformed than we are. If something isn’t the expected type, we should say so.
[quote=150986:@Karen Atkocius]That is a ROYAL UNNEEDED PAIN IN THE BACKSIDE!
I’m sorry but that is ivory tower IT type thinking… Not user friendly BASIC philosophy at work
In science and technology numbers are OFTEN exported from instrumentation with units.
Being able to convert them to a numeric value without having to parse the field is a HUGE time saver…
VAL worked the way it did because it was PRACTICAL for many of not most use cases… If this is the way the new framework is going then perhaps I made a mistake renewing until 2020…
To me stuff like this is akin to having to manage memory yourself and is a waste of time and certainly no fun…
Karen (who is very worried that Xojo will become a PIA language to use rather than a joy!)[/quote]
I understand what Xojo is trying to do : avoid implicit conversions that while convenient, can be source of silent bugs. The problem with returning zero when a text field contains nothing is that in effect, nothing and zero are not at all the same thing. If I forget to put a number in my text variable and use good’ol Val, I get zero and go my merry way without ever realize my mistake.
That said, I have added a lot of little things into a module during beta to wrap the new framework for comfort. Nothing prevents you from creating a Val method that behaves as it has always done, returning zero for “” or “whatever”.
Devil’s Advocate here, but what is the purpose of Xojo if we need to rewrite it to use it as we always have or learn a new API that feels like a combination of Java and Obj-C (and I agree with Karen’s comment)?
As mentioned in other conversations, this kind of change very quickly moves Xojo-based development away from RAD and closer to the other existing language solutions.
[quote=150999:@Norman Palardy]Not doing so is a great opportunity for silently doing something really wrong.
VAL would gladly give you 0 for val"(foo") and your calculation then proceeded to turn out erroneous results.[/quote]
I could live with an exception for “” or “ABC123” but there is not point to throwing an error for “123.5mg”
(you - Xojo inc)… And If we care Just prvide a check function (Text.IsFullyNumeric) for teh times it matters to us.
You really are making Xojo too tedious and getting away from the STRENGTHS of BASIC that made so many of us fall in love with REALBasic compared to other languages.
My point on practical vs purist stands and I am 100% positive this purist approach will make Xojo less popular as it makes writing code feel more like a slog through mud than the RELATIVE joy it has been.
I feel you guys are too close to it to realize the downside of the approach you are taking