Xojo StringUtils Harness API2

Jeannot Muller
Dec 27, 2020 · 2 min read

Joe Strout wrote ages ago a toolset for string manipulations beyond Xojo’s out-of-the-box functionality: http://www.strout.net/info/coding/rb/.

I converted this plugin to Xojo API2, available below:

Update: I meanwhile converted a second library: Xojo ArrayUtils API2

I included the original version for two reasons:

  • Ensuring it won’t get lost
  • And for users who want, for education purposes to convert the original project themselves to API2.

As Joe’s original project contains unit tests, it is a fanastic way to learn (and check) the pitfalls of any conversion to API2. Most of it is a diligent but routine piece of work. However, as a few string manipulator (like string.Middle(x,y) in comparison to Mid(string, x, y) are now finally(!) 0-based and not longer 1-based a particular attention has to be spent on such kind of conversions.

Of course some methods could be renamed as the original command has be renamed as well in Xojo API2, but this was not part of this original version (as well to maintain easier backwards compatibility to older code). This can be added in future releases.

The available methods are:

  • Chop
  • Contains
  • ContainsB
  • Count
  • CountFieldsQuoted
  • CountRegEx
  • DecodeCase
  • EditDistance
  • EncodeCase
  • GuessEncoding
  • HexB
  • InStrQuoted
  • InStrReverse
  • InStrReverseB
  • JoinQuoted
  • LineEnding
  • MatchCase
  • Metaphone
  • NthFieldQuoted
  • PadBoth
  • PadLeft
  • PadRight
  • Random
  • Remove
  • Repeat
  • ReplaceRange
  • Reverse
  • ReverseB
  • Soundex
  • SplitByLength
  • SplitByRegEx
  • SplitQuoted
  • SplitToCDbl
  • SplitToInt
  • SplitToVal
  • Sprintf
  • Squeeze
  • StartsWith
  • StartsWithB
  • SwapBytePairs
  • SwapByteQuads
  • Trim
  • WrapLines

Update: I meanwhile converted Joe Strout’s Xojo ArrayUtils methods to API2 as well.

Disclaimer: As the original toolset this version is, of course, released as public domain. Though most people will just include it in their own workflows (and make adaptions where needed) a contribution on github is highly appreciated in case of any bugs one might find. I don’t have use for all methods. I checked the unit tests, which are all working, but this alone might not yet be a guarantee that the methods are all bug-free.

Learn Xojo

Everything About Developing with Xojo.com

Jeannot Muller

Written by

Managing director at teccompanion.com, physician, founder, developer and blogger.

Learn Xojo

Code snippets, tips and tricks to develop like a pro with the fantastic xojo.com tool on Windows, macOS, iOS, Web and Linux

Jeannot Muller

Written by

Managing director at teccompanion.com, physician, founder, developer and blogger.

Learn Xojo

Code snippets, tips and tricks to develop like a pro with the fantastic xojo.com tool on Windows, macOS, iOS, Web and Linux

Medium is an open platform where 170 million readers come to find insightful and dynamic thinking. Here, expert and undiscovered voices alike dive into the heart of any topic and bring new ideas to the surface. Learn more

Follow the writers, publications, and topics that matter to you, and you’ll see them on your homepage and in your inbox. Explore

If you have a story to tell, knowledge to share, or a perspective to offer — welcome home. It’s easy and free to post your thinking on any topic. Write on Medium

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store