Thanks to Stefano Sarcletti over on our Facebook Group, we now have an even better way to do this! This is version to of this article with the new and improved method.
If you use our File Manager classes then you know we use the UML model to generate our record classes from the Analysis. This works great when you already have an analysis and you are starting fresh with record classes, but starts showing a few chinks in the armor when you need to add a new table later, or modify a table. It becomes very hard keeping the UML in sync.
After I posted the original version of this article, Stefano Sarcletti on our Facebook Group, suggested a slightly different way that cuts off a few steps. Unfortunately it still doesn’t use any of the setting from the programming charters and generates everything with prefixes. But we avoid a few steps with this method regardless.
In this example we have a table in the Analysis called Scenario we need to create a record class for.
- In the project explorer in the Class section right click, and select New -> New server Class. Note I have a custom folder called FileManager, where I store all of out File Manager classes to get them organized, by right clicking on the folder, the class gets created in that folder.
- Name it the same as in the Analysis
- That creates an empty class like this
- Now on the Analysis plane, select all the fields of the table
- And drag and drop then onto the declaration section of the class we created, now your class looks like this
- Click you mouse in front of the first <MAPPING … behind the variables
- Hold down the alt key while holding the left mouse button (you are now in column select mode) and select all the <MAPPING … stuff
- Press Delete
- Now use the same technique to remove all of the m_ from the front of the variables
- What you should have left looks like this
- Click the save button and You Now have record class!!!
If you are generating a bunch of record classes the UML is definitely quicker, especially if you are using the wxPerts charter. But for a quick single record class this sure beats creating by hand, or dealing with other issues related to the UML. We have asked PCSOFT to please add logic so that this method follows the Charter rules, hopefully we can get that in a future release.
Thanks again to Stefano Sarcletti for his contribution to this new method! And if you are not part of our Facebook group, this is exactly the type of collaboration that your are missing out on!