Anyone spend the time converting a desktop app to AP2

Just wondering if anyone has gone through the process of converting an app from to the new controls used in AP2.

If so, was there any shortcuts to the conversion process.

The best shortcut I know is to hire someone with the experience and skill to do it for you. I’ve heard many horror stories from using the menu item (Project > Convert Project to API 2).

4 Likes

Read experiences like: API1 to API2 conversion experience
Understand what you are changing.
Learn about the differences between old and new.
Tests, backups are very important.
If it is very important to you (or you make money) Tim’s answer is best.

You can see in this thread here:

I went ahead and took one more application and did the conversion. Going to Desktop API took 2 and half hours having done it several times before then I knew all the issues I would hit in it which speed-ed it up.

First thing you need to realize is there is no such thing as API2 is one thing. Since the API2 vs not API2 is not Boolean on or off. The story has more sides than that.

So for conversion what you have to do in one go is to go to Desktop API in one round (which is the part I did above in 2 and half hours).

You typically do that by:

  • Let Xojo do the ininital conversion.
  • If you have Plugin controls then go to all your Windows and Dialogs and make sure you update all the plugin controls from xxxx to Desktopxxxx.
  • Manually update events also on plugin controls.
  • If you had classes that inherit from controls then Xojo auto convert also wont help you much on those you will need to do manual fixes there on Events.

Once you have done all the above that you know of then try to build and follow the errors that come up.

Once you have the App building then you have done Desktop API conversion. Note this is not full API 2 conversion.

Full API conversion you can do over time if wanting, as in that does not have to happen all at once like with the Desktop API.

Since I was testing how fast or slow it was to do conversion then I went ahead and did the full API2 all at once also. (doing the full conversion took me 3 nights)

To proceed to do full API2 conversion:

  • Turn on all warnings
  • Do Analyze project (this gave me over 4000 warnings if I remember correctly)

Now from past experience then I knew already that some changes are in such way that you can easily brake your app and create very hard to find bugs. So I had strategy for this this time. Which was to first focus on Obvious things.

Dim you can take care of by doing Search and replace "Dim " "var " (include the space there)
UBound to LastIndex (you have to do it manually no search and replace)
Other such obvious things with no impact on functionality…focus on one thing only if your on UBound then only do Ubound, then its just mechanic work and no risk or low risk of getting confused and creating issues in the code.

Leave more dangerous things like Mid and Instr until very last, those two are particularly dangerous because of the change of 1 based index to zero based.

Weed down all the warnings, also unused variables, put pragmas on unused parameters. Since all those warnings will be noise that get in your way to tackle the actual API2 warnings.

Once its time to do the more dangerous ones then Do tests, in separate App Test like “Mid worked like this…” “what do I have to do to make it work in the new system in same way” once you know that then apply that knowledge in all places (again only doing one single thing at a time not Mid and Instr at same time since thats sure way to get confused and creating huge issues).

So thats the journey I did with 2 and half hours to Desktop API + 3 nights to Full API 2.

Since then there have been few issues with the Application which I don’t remember the details of but it was related to creating Binary files I think. (something there that hit me in the conversion)

8 Likes

my best option was to use the provided menus.

be very careful that string class methods use base 0 and other public string methods use base 1.
unfortunately xojo did not made base 0 or 1 optional.

1 Like

Best options is to do it one window at a time. Convert the App, then the menus, then each window. Then take a look at things like extension methods. That worked best for me.

1 Like

Funny, apart from small ephemeral windows (which I did first), I did everything in the opposite order.

Another thing to note is that you can only use DesktopMenus on DesktopWindow and API 1 Menus on API 1 Windows. So you either have to duplicate your menus first and go step by step for each window or wait until you have them all converted before you test anything. The same goes for code generated menus such as context driven ones. API 2 windows need API 2 MenuItems etc.

We decided to leave well enough alone and keep the legacy apps that are based on API1 as they are and instead of converting them to API2, we are going to create a new starter application based on API2.

This will probably take months because we have 3 or 4 modules with hundreds of methods that have to be converted and a few dozen classes that will have to be converted.

The legacy apps are solid and there no real functionality that API2 can provide for them so we applied the adage “if it isn’t broke, don’t fix it”.

However, we do feel it is worthwhile to create a new starter app that is used to jump start a new application. Our old one is based on API1.

That’s perfectly true, but over time newer features will be API 2 only. An example of that is the new Popovers, they only work with API 2.

2 Likes

I spent a couple of hours a day, over the last 4-5 days converting a large project to API 2.

The VERY LAST STEP was using the Project → Convert to API 2 menu in Xojo.

I started by making a copy of the project, so I could always go back to the original.

Day One

I started by manually converting subclassed UIs/Controls to Desktop Versions, one at a time (by changing the super in the IDE.)

After I converted it, I used Analyze project to see what code broke, and fixed it. A lot of errors were of the “Expecting class Something, got class DesktopSomething. Also a few deprecations to fix, and code that simply did not work and I had to find out what the new method is - ie. MyCanvas.Invalidate(false) became MyCanvas.Refresh(false). Unfortunately there are a number of methods with new names and it’s a PITA to figure out what they are.

Once I updated the subclasses, I’d run the project to make sure nothing else was breaking.

Day Two

Do another Save As, and work on the new copy.

Next I updated all the controls on all the windows, one at a time, checking to see what code broke after each UI control after updating

Day Three

Do another Save As, and work on the new copy.

Manually update all Windows to Desktop windows, and the Menubar and menuitems to desktop versions.

Day Four

Do another Save As, and work on the new copy. I had some bugs to fix, and code to replace (accidentally deleted a line of code that was screwing up opening documents.)

Once that was done, do another Save As, and open the new copy

This is when I finally ran Xojo menu Project → Convert to API 2.

After I used “Convert to API 2”, there were 7 things to fix.

Just straight up converting might have save some work converting controls/UIs, but there would have been thousands of errors and warnings.

Converting them manually means you can keep the project working as you go during Day One and Two - but always keep a backup copy of the original API 1 version.

Converting from API V1 to V2 was difficult for my 2 main applications.
35,000 warnings for one and 25,000 for the other, 12 days versus 8, 130 items (windows, classes, modules, etc.) versus 70.
There are still bugs hidden deep in non-essential functions as the code has been reworked.
On the other hand, once done, the software monitoring is much better and I have the impression that the code executes more quickly.
It’s a real adventure, but it’s worth it.
No regrets, but it was really very difficult to implement.

2 Likes