Replacement for Format?

What about

"123E02B03"

?

[quote=151031:@Michael Diehr]What about

"123E02B03"

?[/quote]

123e02 = 12300

And in a real situation we will know where the number is coming from so we will know how much checking will be needed to determine if it is valid. Numbers with units attached are VERY common.

  • Karen

[quote=151006:@Tim Jones]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]

You may have read the criticisms I had when discovering the new framework that comes in iOS. Was not exactly kind.

Then I proceeded to reuse some of my code. Frankly, apart from ToText I find rather logical, I did not feel like rewriting everything. So I wrapped quite a bit of the new framework into methods, starting with MsgBox.

It works. That’s what counts to me. Not that the new framework looks of feels like this or that. AND I preserve my productivity (RAD, if you will).

I have suffered enough when I wanted to learn Objective-C to appreciate Xojo, even in the new framework. Sure, it is a new dialect, but it remains intrinsically of an RB nature. It is up to me to render it even friendlier through a growing module that contains both methods that wrap the new framework into the older syntax, and declares I need, for instance SetFocus and ClearFocus.

As it is, Xojo iOS exists. Sure, it is not like the RB of 12 years ago. Good enough for me, though.

Are these methods which do the converting publicly available?

I am just getting started with some XOJO iOS stuff. I have used Objective-C and felt it was horrible. I have not tried Swift yet. I used Corona on iOS which is LUA based and I was reasonably comfortable with my RealBASIC and PowerBASIC background.

I am cautiously looking forward to XOJO for iOS but it seems maybe (sorry I don’t have any data yet to back this up) that it is conforming more rigidly to the OS style and standards than possibly necessary. In cases like VAL where there SHOULD be a “RealBASIC” style function included it has been decided that it should be excluded. Yes if you are a “purest” it should be excluded but the reason to use a high level familiar language is to make the job easier. If EVERYTHING is different you might as well switch to Swift or Objective-C. BUT … I know that is not true and it is the little details that will drive us all crazy.

Too bad for the iOS framework some things like VAL and FORMAT did not get ported with the caveat that this is not the “normal” way for this platform. Those that wanted to conform could change their code to be more platform specific and those that did not could simply use VAL with the previously understood consequences.

Interestingly enough NOTHING is normal from the perspective CPU when you look at it from a high level language. No CPU has a PRINT instruction and none really know how to process X = (1 + Y) * Z without breaking it down to some very rudimentary steps like load register, add register A to Register B. Handling precedence and parens is ALL done by the high level language to reorganize the math steps then asking the CPU to perform them in a specific order. With that said you could argue that EVERYTHING in XOJO should work in EVERY platform.

For me I will simply just shrug and start writing my own functions (or maybe as Bob said, an extends method) where things like VAL and FORMAT were missing. I probably would even “tweak” them to do exactly what I wanted and not what the language framework had previously decided was proper. The downside is extra CPU cycles for doing this type of code in a high level language but hopefully today’s hardware can handle it.

I am not trying to be specifically negative here against XOJO. It seems there is ALWAYS something missing in the language no matter which one you use. I have had that issue with XOJO, PowerBASIC, and just about everything I have ever used. Recently I wrote a fairly extensive function to convert time input in just about any crazy way the user wanted to type it to return a normalized output string that was SQL compliant. Why is that not included? Many applications deal with time input. Being “old” I have this “thing” about being able to input stuff into text fields rather than use fancy graphical mouse centric controls with spinners and such to pick times and dates. I do use those also so the user can be either keyboard or mouse centric with THEIR own choice. It is the same perspective we want as programmers so we can make OUR own choice of syntax.

As some have indicated in this topic, they have begun the process to write wrappers to make functions for the old familiar syntax they have grown to love with the new iOS framework hidden inside. Some of the motivation is for the point of productivity and probably some for the sheer elegance of the way they thought it should be.

So maybe somebody should start a forum topic for all of us to contribute their code for the “Missing Functions” that are in other XOJO target platforms and not in iOS. The first two have been identified: VAL and FORMAT.

I don’t know how it can be argued that Format doesn’t exist. You can pass in a format string to the ToText functions.

That one even I found :smiley:

The cool part is that it’s more powerful than the old format function was and the syntax is very well documented :).

Here is the first of no doubt a long series. This module contains the functions I needed to adapt older code, plus a couple declares (setfocus/clearfocus) needed to activate and remove the keyboard in code in the Textfield or TextArea.

wrapper.xojo_binary_code

Richard, I just edited my post above with a module containing my first wrappers. For use, simply drag the downloaded file into your project.

Thank you for sharing that with the community Michel - much appreciated.

I didn’t say I wouldn’t check for it, but if it’s then MY method that I’m responsible. You guys are off the hook - my problem.

You’re trying to make a complex process idiot proof and in the process made it more complex.

Yeah- it’s never easy. Do you make it “more complex” up front with fewer issues down the line, or “less complex” up front with more issues down the line?

But like anything- if someone here would like to see a way for something like Integer conversion in the new framework to be a bit more liberal in what it considers an error, you can always file a feature request and vote. I’m not sure I (personally) agree…but only fool thinks they’re never wrong :slight_smile:

This type of thing won’t garner a lot of votes, but it WILL annoy a lot of people and make them enjoy coding in Xojo less. In that long run that can a be negative for Xojo inc.

You are trying way too hard to save us from ourselves… and in doing that you are heading towards making Xojo way more complex to do simple things than it has ben or has to be to be a great tooll and long with that making it much more of a pain to use.

From what I can see this type of stuff will tend to discourage beginners and annoy the experienced…

People chose a language grounded in BASIC because it is easy to use… and this type of stuff makes it significantly less so…

Here’s NthField for your wrapper if you want it. Got it from Greg during the beta.

function NthField(txt as Text, delimiter as Text, index as integer) as Text
  Dim parts() as Text = txt.split(delimiter)
  Return parts(index-1)
End Function

[quote=151301:@Albin Kiland]Here’s NthField for your wrapper if you want it. Got it from Greg during the beta.

function NthField(txt as Text, delimiter as Text, index as integer) as Text Dim parts() as Text = txt.split(delimiter) Return parts(index-1) End Function [/quote]

Thank you Albin. I have added it and updated the file.

wrapper.xojo_binary_code

So it seems that Michel is the man to visit, in order to receive a combined set of iOS wrapper functions.
We just need to now get it on GitHub or dropbox, so that there is a centralised location :slight_smile:

[quote=151353:@Richard Summers]So it seems that Michel is the man to visit, in order to receive a combined set of iOS wrapper functions.
We just need to now get it on GitHub or dropbox, so that there is a centralised location :)[/quote]

It should be possible to post the module on Github. I simply never did it for Xojo code. I shall look it to it.

How hard would it have been to have Xojo implement Text.Val() that worked the way that people expect based on years of Xojo usage?

Michel - I am always happy to put the module on dropbox for you if need be?
Simply send me any updates, and I will put it up on my dropbox.