PDA

View Full Version : Application Language and Code Cleanup



Clive Richmond
26-Jul-2018, 12:17 AM
Over the last week we have spent some time prepping our application source for DataFlex 19.1 using the alpha 3 release. The main goal was to take advantage of the new source code warning system and see how much code we would need to clean up. I have published our findings below as it may be of interest. The findings relate to our main windows application which is about 56MB when compiled.

The table below shows the before and after our code clean up.



Before
After


Errors
12
0


Warnings
1125
118



The warnings that remain relate to classes that we still use such as the old Grid and Crystal. The list below are the distinct warning messages.

In our source code.
WARNING: 4533 Obsolete command: End_Item_List
WARNING: 4533 Obsolete command: Item_List
WARNING: 4537 Obsolete class: PROTOTYPE_ENTRY

The graphic's library
WARNING: 4532 Obsolete command: ZeroString. Use ZeroString(iLen) global function

The DAW packages.
WARNING: 4536 dfbase.pkg is obsolete and can be removed ON LINE: 1 (43663) OF FILE: d:\Apps\6.1\AppSrc\pkg-daw-v19.1\Dfbase.pkg
WARNING: 4536 Dftabdg.pkg is obsolete and can be removed ON LINE: 1 (45154) OF FILE: d:\Apps\6.1\AppSrc\pkg-daw-v19.1\Dftabdg.pkg
WARNING: 4536 Dfcmbfrm.pkg is obsolete and can be removed ON LINE: 1 (45482) OF FILE: d:\Apps\6.1\AppSrc\pkg-daw-v19.1\Dfcmbfrm.pkg
WARNING: 4536 cCrystal.pkg is obsolete ON LINE: 2 (128201) OF FILE: d:\Apps\6.1\AppSrc\pkg-daw-v19.1\cCrystal.pkg
WARNING: 4536 cCrystalcraxddrt.pkg is obsolete ON LINE: 1 (128201) OF FILE: d:\Apps\6.1\AppSrc\pkg-daw-v19.1\cCrystalcraxddrt.pkg
WARNING: 4536 cCrystalcdo32.pkg is obsolete ON LINE: 1 (139579) OF FILE: d:\Apps\6.1\AppSrc\pkg-daw-v19.1\cCrystalcdo32.pkg
WARNING: 4536 cCrystalActiveXReportViewer.pkg is obsolete ON LINE: 1 (139682) OF FILE: d:\Apps\6.1\AppSrc\pkg-daw-v19.1\cCrystalActiveXReportViewer.pkg
WARNING: 4533 Obsolete command: External_Function32. Use External_Function ON LINE: 25 (143519) OF FILE: d:\Apps\6.1\AppSrc\pkg-daw-v19.1\globmem.pkg
WARNING: 4536 cReportDS.pkg is obsolete ON LINE: 1 (256124) OF FILE: d:\Apps\6.1\AppSrc\pkg-daw-v19.1\cReportDS.pkg
WARNING: 4536 cReport.pkg is obsolete ON LINE: 1 (256124) OF FILE: d:\Apps\6.1\AppSrc\pkg-daw-v19.1\cReport.pkg
WARNING: 4536 Obsolete Package: dfsellst.pkg. Use cDbCJGridPromptList class ON LINE: 1 (301600) OF FILE: d:\Apps\6.1\AppSrc\pkg-daw-v19.1\Dfsellst.pkg
WARNING: 4533 Obsolete use of EQ/GT/GE/LT/LE/NE in If statement. Use = > >= < <= <> inside expression () ON LINE: 113 (317275) OF FILE: d:\Apps\6.1\AppSrc\pkg-daw-v19.1\RgbColor.pkg
WARNING: 4536 Obsolete Package: dftxtwin.pkg. Use cTextEdit class ON LINE: 1 (412545) OF FILE: d:\Apps\6.1\AppSrc\pkg-daw-v19.1\Dftxtwin.pkg
WARNING: 4536 Obsolete Package: dftable.pkg. Use cCJGrid or cCJDbGrid class ON LINE: 1 (427764) OF FILE: d:\Apps\6.1\AppSrc\pkg-daw-v19.1\Dftable.pkg
Prior to the code clean up most of the errors related the symbols already defined in the graphics library but also collected some bad syntax statements in our own code E.g. Get MyProperty(Self) To Value.

The majority of warnings related to use of obsolete commands or packages that were changed or removed respectively. We had some macros which we updated to turn the compiler warnings off and on. And while the total warnings looked daunting at first many of the messages were duplicates for the same issue. As each warning was addressed e.g. Indicate the warnings total would dropped rapidly.


WARNING: 4531 Obsolete String command: Replace. Use Replace() Function
WARNING: 4532 Obsolete command: End_Type. Use Struct/End_Struct
WARNING: 4532 Obsolete command: Field. Use Struct/End_Struct and variable types
WARNING: 4532 Obsolete command: GETBUFF. Use Structs and Move
WARNING: 4532 Obsolete command: Put. Use Structs and Move
WARNING: 4532 Obsolete command: Type. Use Struct/End_Struct
WARNING: 4532 Obsolete command: ZeroString. Use ZeroString(iLen) global function
WARNING: 4532 Obsolete command: ZeroType. Use Structs and it's not needed
WARNING: 4533 Obsolete Command: ArrayPut
WARNING: 4533 Obsolete command: End_Item_List
WARNING: 4533 Obsolete command: External_Function32. Use External_Function
WARNING: 4533 Obsolete command: GetAddress. Use AddressOf Function
WARNING: 4533 Obsolete command: Get_Date_Attribute. Use Get_Attribute DF_DATE_FORMAT
WARNING: 4533 Obsolete command: Gosub
WARNING: 4533 Obsolete command: Item_List
WARNING: 4533 Obsolete Command: Local. Local is not needed
WARNING: 4533 Obsolete command: Set_Date_Attribute. Use Set_Attribute DF_DATE_FORMAT
WARNING: 4533 Obsolete command: Sysdate4. Use CurrentDateTime() function
WARNING: 4534 |CI22925(|VI85))__$obs
WARNING: 4534 |CI34964)__$OBS
WARNING: 4534 Obsolete Global Function: CVTTOBYTES
WARNING: 4535 Do not use indicators in If statements, use expression if (var)
WARNING: 4535 Filenames in use command should contain a file extension (e.g., .pkg)
WARNING: 4535 Use of Private or Public keyword in property command is obsolete
WARNING: 4536 ArrayPut.pkg is obsolete
WARNING: 4536 cAttachmentsArray.pkg is obsolete
WARNING: 4536 cCrystalActiveXReportViewer.pkg is obsolete
WARNING: 4536 cCrystalcdo32.pkg is obsolete
WARNING: 4536 cCrystalcraxddrt.pkg is obsolete
WARNING: 4536 cCrystal.pkg is obsolete
WARNING: 4536 cMapiHandler.pkg is obsolete
WARNING: 4536 cReceipientsArray.pkg is obsolete
WARNING: 4536 cReceiversArray.pkg is obsolete
WARNING: 4536 cReportDS.pkg is obsolete
WARNING: 4536 cReport.pkg is obsolete
WARNING: 4536 dfbase.pkg is obsolete and can be removed
WARNING: 4536 Dfcmbfrm.pkg is obsolete and can be removed
WARNING: 4536 Dftabdg.pkg is obsolete and can be removed
WARNING: 4536 MapiDllCalls.pkg is obsolete
WARNING: 4536 MapiSession.pkg is obsolete
WARNING: 4536 Obsolete Package: dfDeoMnu.pkg is obsolete. Use cCJCommandBarSystem class
WARNING: 4536 Obsolete Package: dfmenu.pkg. Use cCJCommandBarSystem class
WARNING: 4536 Obsolete Package: dfsellst.pkg. Use cDbCJGridPromptList class
WARNING: 4536 Obsolete Package: dftable.pkg. Use cCJGrid or cCJDbGrid class
WARNING: 4536 Obsolete Package: dftxtwin.pkg. Use cTextEdit class
WARNING: 4536 winbase.pkg is obsolete and can be removed
WARNING: 4537 Obsolete class: PROTOTYPE_ENTRY
WARNING: 4538 Obsolete command: Indicate. Use Move command
WARNING: 4538 Obsolete technique. Do not define indicators or use them in expressions without parentheses

Stephen W. Meeley
26-Jul-2018, 07:11 AM
Clive,

Nice overview. Thanks.

Did these number include any or all of the "pickier" warnings (IfExp , Item or IfLine) that were configurable starting in Alpha 3?

Clive Richmond
26-Jul-2018, 10:43 PM
Hi Stephen,


Did these number include any or all of the "pickier" warnings (IfExp , Item or IfLine) that were configurable starting in Alpha 3?

Yes, but only IFExp.

Item we will try. No doubt it will report many more warnings due to our use of the old grid. However, it will at least allow us to clean up usage elsewhere.

Ifline I may try. We currently have no plans to change our coding style especially with regards to simple statements e.g. If (x = y) Move (True) To bDone. My thoughts about line continuation and debugging can be found here (https://support.dataaccess.com/Forums/showthread.php?62798-Splitting-an-if-else-case-line-with-a-line-separator-(-)-will-make-it-easier-to-debug&p=335698#post335698):). So, trying this will be about collecting any syntax anomalies than breaking lines.

I have just been reading about Michael’s DataFlex Code Parser (https://support.dataaccess.com/Forums/showthread.php?62959-DataFlex-Code-Parser-Explorer-Update&highlight=parser). I definitely want to give this a run and see what else might be 'hiding' in our source code.

Clive Richmond
30-Jul-2018, 10:36 AM
Item we will try. No doubt it will report many more warnings due to our use of the old grid. However, it will at least allow us to clean up usage elsewhere.

Turned on the above and, as expected, the warnings jumped (4K+). The code changes have been made and the warnings are back to our original post.