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.
Andy discovered a new way to generate record classes, and it works great with a few exceptions. Unfortunately it doesn’t use any of the setting from the programming charters and generates everything with prefixes. Andy has likely show everyone this new method in his recent videos but I figured I would do a write up on the blog with some step by steps for everyone.
In this example we have a table in the Analysis called BudgetType that we need to create a record class for.
- In the project explorer at the bottom, you will see your analysis listed, right-click on the table and select “Generate a model Class”
- It pops up and wants to add to the SCM click cancel because we are going to rename it, etc. first
- That created a class that looks like this
- Remove the M in front of BudgetType and the line <MAPPING … stuff from the first line
- Important! Do not click save until you have done all of the below steps or it will confused things between logical name and file name
- Remove the french comments (unless you want to study your french) and the <MAPPING> line
- 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
- Remove the <END> line
- What you should have left looks like this
- From the Home ribbon bar do a File Save As
- Remove the M so it is called BudgetType
- Now Right click on the MBudgetType in the project explorer and delete it
- 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.