Unused Variables Tool (Navision)
Will help you to find and remove unused Global and Local variables. You can simultaneously search in many objects (it is desirable that the size of the Text File was no more than 10 Mb).
It can be used in versions 3. and above.
Here results of search in a database NAV3.70W1
• Table (linked to Unused Variables 370W1Tab.htm)
• Form (linked to Unused Variables 370W1 Form.htm)
• Report (linked to Unused Variables 370W1 Rep.htm)
• Codeunit (linked to Unused Variables 370W1 CU.htm)
Working method:
• Export objects in the form of the Navision Text File.
• Run Form 70100 "Unused Variables".
• Specify the path of Export File.
• Click the Variables - Search Unused.
http://www.mibuso.com/dlinfo.asp?FileID=537
Discuss this download here.
Comments
I just did a quick test on one of our objects and i have 1 bug and 2 sugestions for you:
bug:
- when you cancel the search variables proces, the file remains locked until you close the form (not a big issue and probably hard to overcome, but i just wanted you to know).
sugestions:
- we sometimes use variables just as a seperator, so our code remains human readable. This means that these variables are intended to be unused and should never be removed. Maybe you could add some kind of filter (that can be set by the user) to ignore variable names that meats some critearia. Like for example variables witch the character '#' in its name.
- when opening a file, check that the first 6 characters for the string "OBJECT". The first thing i did was accidentally export the object as a text file but still in binary (fob) format and the program didnt warn me ](*,)
My computer uses “/” as a DD/MM/YY separator so the export routine was trying to create a file called “t_Modifyed_25/11/05_1.txt”. Windows didn't like this at all so I had to add a line of code to delete the “/” – easy enough. Also, it doesn't spot locals/globals used as the value of a DataCaptionExpr property of a form.
Bottom line: I love it!
Stebbi
I analysed 4200 lines of code and then removed the not used variables with the "delete unused" and compared the result file to the origin file.
110 lines of code were deleted...
But it helped me to find the not used variables
If you have found mistakes at removal of variables send those to me one of objects, please. It will be rather interesting for analysing. I use this tool already more than year and yet did not see any mistake.
E.g.:
IF ((STRPOS(ActualLineP,'On') <> 0) AND (BeetweenText(ActualLineP,'On') = FALSE)
AND (STRPOS(ActualLineP,'=VAR') <> 0) AND (BeetweenText(ActualLineP,'VAR') = FALSE))
THEN BEGIN
BeginStackG := 0;
CheckG := TRUE;
justswitchedG := TRUE;
IF STRPOS(ActualLineP,ComL) > 0 THEN
ActualLineP[STRPOS(ActualLineP,ComL)] := ' ';
END;
IF ((STRPOS(ActualLineP,'CASE ') <> 0) AND (BeetweenText(ActualLineP,'CASE') = FALSE)
AND (STRPOS(ActualLineP,'OF') <> 0) AND (BeetweenText(ActualLineP,'OF') = FALSE))
THEN BEGIN
ZeilePruefen_isCommentOpen(ActualLineP,'CASE');
keycheckL := TRUE;
IF (NOT (ZeilePruefen_isComment(ActualLineP, 'CASE')) AND ((zp_isOpenG = 2) OR (zp_isOpenG = 66) OR (zp_isOpenG = 0))) THEN
BeginStackG := BeginStackG +1;
END;
Result:
IF ((STRPOS(ActualLineP,'On') <> 0) AND (BeetweenText(ActualLineP,'On') = FALSE)
BeginStackG := 0;
CheckG := TRUE;
justswitchedG := TRUE;
keycheckL := TRUE;
BeginStackG := BeginStackG +1;
Anyway, I have a suggestion for improvement: a filter on variable ID's. I do not want to delete unused variables from standard navision because this the code difficult to maintain.
Kind Regards,
Ron
I agree with ronvdw. I don't want to change standard Navision code to avoid problem with further ugrade.
I just want to delete my unused variables (with my ID).
I agree with all together : Nice tool !
Will help you to find and remove unused Global and Local variables. You can simultaneously search in many objects (it is desirable that the size of the Text File was no more than 10 Mb).
It can be used in versions 3. and above.
Working method:
• Export objects in the form of the Navision Text File.
• Run Form 70100 "Unused Variables".
• Specify the path of Export File.
• Click the Variables - Search Unused.
New version:
Added filters for Variable-ID and Variable-Name to exclude from search standard Navision variables or variables set by the user.
http://www.mibuso.com/dlinfo.asp?FileID=537
Discuss this download here.
I wast just planning on using your tool today now i can use the new version and don't have to manually delete var names! :P \:D/
=D>
I also Exerienced the NewFileName Error on the CodeUnit 70100.
I corrected it by Changing the Format(TODAY) code to
FORMAT(TODAY,0,'<Day,2>-<Month,2>-<Year4>').
Thanks =D>
But I have some problems with some code in Codeunits.
For that reason I have added an example:
PROCEDURE AppServer_BatchManager
VAR
SetupRec@1160230001 : Record 6010300;
BEGIN
IF ISCLEAR(Batch_Manager_Timer) THEN
CREATE(Batch_Manager_Timer);
SingleInstance.Get_SetupRec(SetupRec);
Batch_Manager_Timer.Enabled := FALSE;
Batch_Manager_Timer.Interval := 30000;
Batch_Manager_Timer.Enabled := TRUE;
in_ATASStarted := TRUE;
MESSAGE(Text001,in_Parameter,Batch_Manager_Timer.Interval);
END;
SetupRec is use within the code: SingleInstance.Get_SetupRec(SetupRec);
But the tool marks it as unused.
I did not have the time to dig in it but I would like to inform you regarding that feature.
As a suggestion I would like to ask for a function that skips objects that do not have unused variables when creating the new file.
Another solution could be in changing the Version text or to set the modified flag.
But still - it is a great tool!
Regards
Kappe
Kappe