Joe Strout wrote ages ago a toolset: ArrayUtils Module for manipulations of arrays beyond Xojo’s out-of-the-box functionality.
I converted this plugin to Xojo API2, available below, and included the original code for archiving purposes.
For string manipulations, please look here.
Thank you for doing these conversions, I wondered what had become of them.
Thank you @John_McKernon. Joe doesn’t seem to develop with Xojo any longer. Some of the other contributors are still on board, but they probably just changed the code themselves, or not at all (as we don’t really need to change it).
I did this exercise to train myself in API2 and then I had the idea of sharing it as it might be useful to others as well. I wrote an article on my experience, FWIW .
One thing you might add in your project (since we are starting afresh) is to replace ReDim with the new Arrays.ResizeTo.
As the documentation says:
Redim exists for Visual Basic compatibility only. Use Arrays.ResizeTo instead.
Thanks a lot for your contribution. For me, it is a great exercise to work through and understand tested code. I also can add it to my toolset.
@Robert_Livingston thank you very much for bringing this to my attention. I created an own article to collect these (and potentially future) changes and I added you to the notes as a contributor.
I like that you embraced my recommendation to run the exercise on your own.
I really believe it is the best way to better understand the changes. Overall they are simple, but it is a change in mindset, and we need to get used to it. Funny thing is that it took me years to remember where Xojo was 1-based, but now I’m struggling sometimes to keep in mind that everything is now 0-based
This remains a problem for me. My “other” two languages are 4D and Python. The former is one-based and the latter zero-based. Xojo has a new method FirstIndex which is the companion to LastIndex. In API2, it always returns zero. Whether the use of this helps me or hurts me in terms of migrating my brain is not really clear. But it is available.
@Robert I hear you. But at least it is now always 0-based. It still confuses me sometimes too, especially when working in 1-based solutions. But the fact that Xojo was mixing both up for a very long time, drove me sometimes completely nuts. So it is at least some progress in my daily work ;-).