Spring Cleaning with SRP Utilities 1.5.7
SRP is pleased to announce the release of SRP Utilities 1.5.7. In addition to a critical fix and a new method called SRP_String, this version also introduces some quality of life improvements in the form of simplified wrappers around existing functionality.
We use SRP Utilities everywhere, including other commercial products. The SRP HTTP Framework is no exception. That tool uses SRP_JSON quite extensively, and thanks to the patient investigative efforts of our customers, we discovered a critical (though easy to fix) bug that only manifested when dealing with multi-byte UTF8 characters. While we noticed these issues for quite some time, our investigations seemed to point to OECGI, but as it turned out, it all boiled down to a single letter. SRP Utilities makes calls to the SRPUtilities.dll, and the DLL stubs we defined used LPASTR instead of LPSTR. We incorrectly understood LPASTR to mean “pass variables as is” to the DLL, which it really means, “pass variables as ANSI.” It’s an important distinction since when the UTF8 flag is on, OI will convert all UTF8 characters to ANSI before passing them to the DLL. LPSTR is what we needed to be using as it is the functional equivalent of passing strings as is to the DLL, which is what the DLL expects. We’re not sure how we got this far without finding this error, but we have accepted our failure, fixed it, and now give you a sturdier toolkit.
Putting that bit of shame behind us, we did add new functionality to this release in the form of a function called SRP_String. Like most SRP Utilities features, this is a single function providing multiple services. In this case, the services are centered around manipulating BASIC+ strings. There are only three services to start, but we expect this method to gain new services as opportunities arise. One of the services, Trim, is just a wrapper around SRP_Trim. You can use either function, but it was clear that the functionality of SRP_Trim, which is a more advanced version of OI’s Trim functionality, fit well within SRP_String. SRP_String also introduces two new functions for measuring strings that will be rendered on screen. The GetWidth service calculates the width, in pixels, that will be occupied by a string given a certain font. Likewise, the GetHeight service calculates the height, in pixels, that a word-wrapped multi-lined string will occupy given a font and a maximum width. Both of these are useful for sizing a control or SRP Popup to be exactly large enough to fit your text.
Lastly, we’ve done a bit of Spring cleaning in this release. There are four new functions that are merely service oriented wrappers around existing methods: SRP_Array, SRP_FastArray, SRP_List, and SRP_HashTable. You might wonder why these functions didn’t exist in the first place. The answer is speed. It was assumed that a service oriented wrapper would add too much undesirable overhead to functions that were created for performance above all else. In practice, however, we found that people avoided using tools like SRP FastArray and SRP List because there were so many individual methods. Using them always meant going to the web to read our wiki documentation just to remind ourselves of all the features. What good is the performance benefit if no one uses them in the first place? Thus, the service oriented wrappers were born, and to our delightful surprise, there was barely any overhead at all in our benchmark tests. Hopefully, the convenience of these service oriented wrappers (which are only really convenient in the SRP Editor thanks to the accompanying metadata), we hope you will be encouraged to use these features more often in your code.
Note that the wrappers do not deprecate the original stand-alone methods at all, but we did de-emphasize the old routines in our wiki. You’ll still find them, but they will be tucked away beneath the documentation of their respective wrappers. For example, within the SRP_List node of the wiki’s navigation tree, you’ll find SRP List Raw Methods. Whether you choose to use the new wrappers or the old raw methods, SRP Utilities also now ships with Inserts to make it a snap to start using our speedy lists and arrays. Need to use hash tables? Just insert SRPHASHTABLE at the top of your code and you’re all set.
We hope you enjoy these additions to this free toolset. As always, we look forward to you feedback and suggestions in our community forums.
Where’s the ‘Like’ button? 😉
That’s why we have a Facebook page! 🙂