Options

Unused Variables Tool (Navision) Update

AdministratorAdministrator Member, Moderator, Administrator Posts: 2,496
edited 2006-09-08 in Download section
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

  • Options
    janpieterjanpieter Member Posts: 298
    Nice tool ! =D>

    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 ](*,)
    In a world without Borders or Fences, who needs Windows and Gates?
  • Options
    stebbijonsstebbijons Member Posts: 2
    Nice tool! Just ran this on a 50 object module. I'm the kind of person who *hates* globals so I've been changing globals to locals where I can. This tool found a lot of variables that weren't used any more and when I re-imported the .txt file they were all gone and everything worked. Well kind of…

    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
  • Options
    STKSTK Member Posts: 9
    It's a nice tool but a little bit dangerous to trust in it

    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
  • Options
    EdSanEdSan Member Posts: 2
    Dangers are not present, as the new text file is created, and the original file remains without changes. You have always an opportunity to compare both of a file and to use any of them.
    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.
  • Options
    STKSTK Member Posts: 9
    I believe that you haven't found any mistakes. But I'm building a Tool which corrects the Styleguide of *.txt files (Spaces, not allowed combinations like THEN REPEAT and so on...) with a lot of Keywords in it and i think thats the problem

    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;
  • Options
    ronvdwronvdw Member Posts: 16
    I have tried this tool for several object files and it seems to work perfectly. Good work!

    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
    Connectivity Studio for Microsoft Dynamics NAV - Where Microsoft Dynamics NAV meets the world
  • Options
    cwatrelotcwatrelot Member Posts: 14
    I agree with stebbijons with date '/' separator problem and just replace format(TODAY) by format(TODAY,6). DD/MM/YY is now YYMMDD.

    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 !
  • Options
    AdministratorAdministrator Member, Moderator, Administrator Posts: 2,496
    Unused Variables Tool (Navision) Update
    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.
  • Options
    janpieterjanpieter Member Posts: 298
    Thanks !

    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/
    In a world without Borders or Fences, who needs Windows and Gates?
  • Options
    sggsgg Member Posts: 109
    Great Tool.
    =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>
    Sunday, Godwin G
  • Options
    KappeKappe Member Posts: 64
    Great Tool! \: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
  • Options
    vivySarmavivySarma Member Posts: 1
    DO we have this tool for NAV 2017? please help!!
Sign In or Register to comment.