PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197

PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197
[vb6] Project Scanner - Page 6-VBForums
Page 6 of 6 FirstFirst ... 3456
Results 201 to 214 of 214

Thread: [vb6] Project Scanner

  1. #201
    Fanatic Member
    Join Date
    Feb 2019
    Posts
    521

    Re: [vb6] Project Scanner

    Quote Originally Posted by dreammanor View Post
    Hi LaVolpe,

    The original version of Project Scanner cannot handle Chinese characters, and now the new version can. I'd like to know what steps you've taken to deal with Chinese characters? Thanks!
    You can use WinMerge to see what changed between two VB projects.

  2. #202
    Frenzied Member
    Join Date
    Sep 2012
    Posts
    1,834

    Re: [vb6] Project Scanner

    Quote Originally Posted by qvb6 View Post
    You can use WinMerge to see what changed between two VB projects.
    Hi qvb6, the tool you recommend is extremely useful, thank you very much.

  3. #203
    Fanatic Member
    Join Date
    Feb 2019
    Posts
    521

    Re: [vb6] Project Scanner

    Quote Originally Posted by LaVolpe View Post
    - Zombie declarations and procedures. Items that are created/declared but not referenced within your code
    - Strings that are duplicated within your code. These can be consolidated to constants
    I haven't downloaded your Project Scanner yet, but from memory; I know that VB6 compiler omits procedures that are not called from anywhere(unless they are Public in a Class, I think). This is called function-level linking in the C world. Also, VB consolidates duplicate string literals into one, so it appears once in the EXE space, but in some cases using constants is better.

  4. #204
    Frenzied Member
    Join Date
    Feb 2017
    Posts
    2,009

    Re: [vb6] Project Scanner

    Hello LaVolpe, I found a bug in the pvScanProcedures procedure of clsPrjFile. It raises an error in the line:

    Code:
    sToken = Mid$(sLine, iPos + 1, lFlags - iPos - 1)
    because lFlags is 0.

    I traced the error and it is misinterpreting a line that is:

    Code:
    Static sVariableName as Boolean
    It is interpreting it as it was a Static procedure.

    It is a bit strange because I have several other Static variables in the project but they didn't rise the error.

    I momentarily fixed it by adding these lines:

    Code:
        Do
            iPos = 0: sToken = modMain.GetToken(sLine, iPos, chrSpace)
            If lScope = 0 Then
                If sToken = ITEM_STATIC Then
                    sToken = modMain.GetToken(sLine, iPos, chrSpace)
                End If
                Select Case sToken
                Case ITEM_PUBLIC, ITEM_PRIVATE, ITEM_FRIEND
                    If sToken = ITEM_PRIVATE Then
    Because even when a procedure is Static, it also must have Sub, Function, Etc.

  5. #205
    Frenzied Member
    Join Date
    Feb 2017
    Posts
    2,009

    Re: [vb6] Project Scanner

    Update. I found the cause. I was experiencing other anomalies and the cause are some commented lines that end with _ (underscores).

    It seems that the scanner intrerprets all lines finished with underscores as continuation to the next line. But that rule doesn't actually apply to comment lines, it is only for code lines.

    Also another detail: The procedure named 'Main' in a bas module shouln't be listed as zombie because "it is not used".
    Last edited by Eduardo-; Oct 2nd, 2019 at 12:28 AM.

  6. #206

    Thread Starter
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    18,597

    Re: [vb6] Project Scanner

    Quote Originally Posted by Eduardo- View Post
    Update. I found the cause. I was experiencing other anomalies and the cause are some commented lines that end with _ (underscores).

    It seems that the scanner intrerprets all lines finished with underscores as continuation to the next line. But that rule doesn't actually apply to comment lines, it is only for code lines.

    Also another detail: The procedure named 'Main' in a bas module shouln't be listed as zombie because "it is not used".
    Good catches. I do want to return to this project and finish it up. I'll keep these in mind when I come back to this project. If not, I'll ensure that is addressed too.

    Sub Main(): I'm not looking at my code, but I thought I only mark it zombie if it isn't the startup routine and no other code calls it.

    Underscores on comments: Yep, didn't expect those. Will need to tweak the line parser for that scenario.
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  7. #207
    Frenzied Member
    Join Date
    Feb 2017
    Posts
    2,009

    Re: [vb6] Project Scanner

    Quote Originally Posted by LaVolpe View Post
    Sub Main(): I'm not looking at my code, but I thought I only mark it zombie if it isn't the startup routine and no other code calls it.
    Yes... I had forgot to select the Sub Main in the project properties (it is a component).
    Now that I fixed that, it disappeared from the zombie report.
    The scanner is working fine in that regard, then.

    Quote Originally Posted by LaVolpe View Post
    Underscores on comments: Yep, didn't expect those. Will need to tweak the line parser for that scenario.
    Yes, it is then the only thing I'm reporting.

    For my case, I already changed those comment lines to avoid underscores at the end.

    Thank you.

  8. #208
    Frenzied Member wqweto's Avatar
    Join Date
    May 2011
    Posts
    1,720

    Re: [vb6] Project Scanner

    Line continuations (underscores) *do* work for comment lines like this.

    thinBasic Code:
    1. Option Explicit
    2.  
    3. Private Sub Form_Load()
    4.     Rem First line _
    5.         Second line
    6.        
    7.     '-- First line _
    8.         Second line
    9. End Sub
    . . . both first and second lines are part of the comment or am I not understanding the problem?

    cheers,
    </wqw>

  9. #209

    Thread Starter
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    18,597

    Re: [vb6] Project Scanner

    @wqweto, that is how I believe I coded the scanner now that I am thinking about it more. I know I've used comments like that in the past -- looks more pleasing to my eyes with just one tick/REM statement

    @Eduardo, is this the scenario that was triggering false positives..
    Code:
    Static sVariableName as Boolean ' some comments _
    If not, could you provide a simple example so I can look at the code in more detail down the road?

    It may have interpreted it as a method, but shouldn't have. I'm pretty sure the code requires Sub, Function, Property to flag methods. My guess is that the flags were simply wrong due to failed parsing and 'method' is just a byproduct of bitwise comparison of the faulty flag value.
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  10. #210
    Frenzied Member
    Join Date
    Feb 2017
    Posts
    2,009

    Re: [vb6] Project Scanner

    LaVolpe, in the case of the Static variable, the scan process was silently aborted because of a runtime error. The scanner didn't work at all until I traced the issue to that procedure and made that change.

    But after that, I found others issues, this time as false positives like variables not used when they were in fact used. I had several cases like that.

    About the issue of line continuations in comment lines, I see what wqweto points (thanks). Then, perhaps it is not that comments lines are handled differently by VB regarding to line continuations, but that line continuations require one space before the last underscore?

    Here is a sample of what caused the problem:

    Code:
    ' declarations...
    ' declarations...
    
    '_SOME_COMMENT_
    ' declarations...
    Private mVariable As Long ' mVariable Reported as not used
    ' declarations...
    '_
    
    ' code...
    ' code...
    
    '_SOME_COMMENT_
    Private Sub NameOfSub()
        Static sVariable As Boolean ' Static variable that caused the run time error
        
        If Not sVariable Then
            sVariable = True
            ' code...
    
            ' code...
        End If
    End Sub
    '_
    
    ' code...
    ' code...
    
    '_SOME_COMMENT_
    Private Function F1() As Boolean
        Dim i As Long
     
        ' code...
    
        i = mVariable ' mVariable is used
    
        ' code...
    End Function
    '_
    Or simpler, causing only the first problem:

    Code:
    ' code...
    ' code...
    
    '_SOME_COMMENT_
    Private Sub NameOfSub()
        Static sVariable As Boolean ' Static variable that caused the run time error
        
        If Not sVariable Then
            sVariable = True
            ' code...
    
            ' code...
        End If
    End Sub
    '_

  11. #211

    Thread Starter
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    18,597

    Re: [vb6] Project Scanner

    The problem is likely the trailing underscore. I know I coded to ensure a 'space underscore' is a continuation, but may not have done that for comments. I doubt it is the leading underscore. In any case, I'll need to check the code in more detail.

    Thanx Eduardo for the bug report
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  12. #212
    Frenzied Member
    Join Date
    Feb 2017
    Posts
    2,009

    Re: [vb6] Project Scanner

    Quote Originally Posted by Eduardo- View Post
    Code:
    ' code...
    ' code...
    
    '_SOME_COMMENT_
    Private Sub NameOfSub()
        Static sVariable As Boolean ' Static variable that caused the run time error
        
        If Not sVariable Then
            sVariable = True
            ' code...
    
            ' code...
        End If
    End Sub
    '_
    After I changed the comments to:

    Code:
    ' code...
    ' code...
    
    '_SOME_COMMENT_1
    Private Sub NameOfSub()
        Static sVariable As Boolean ' Static variable that caused the run time error
        
        If Not sVariable Then
            sVariable = True
            ' code...
    
            ' code...
        End If
    End Sub
    '_2
    all the problems went away.

  13. #213
    Frenzied Member wqweto's Avatar
    Join Date
    May 2011
    Posts
    1,720

    Re: [vb6] Project Scanner

    So the problem is that in comments trailing underscore has to be space prefixed to be treated as line continuation by the parser.

    Here is another sample where no comment/code continuation should happen

    thinBasic Code:
    1. Option Explicit
    2.  
    3. Private Line_ As Long
    4.  
    5. Private Sub Second(A As Long)
    6.  
    7. End Sub
    8.  
    9. Private Sub Form_Load()
    10.     '-- First Line_
    11.         Second Line_
    12. End Sub

    Not that final underscore can be part of variable name in normal code lines so space-underscore combo is actually required to be non-ambiguous.

    cheers,
    </wqw>

  14. #214
    Lively Member
    Join Date
    Jan 2018
    Posts
    106

    Re: [vb6] Project Scanner

    I thought of another check that would be useful under the "zombie" category - labels without a corresponding Goto or On Error Goto. It would catch some non-functioning error handlers.

Page 6 of 6 FirstFirst ... 3456

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width