Results 1 to 12 of 12

Thread: Turns out program is running so fast that using datetimeserial wasn't giving uniques

Threaded View

  1. #1

    Thread Starter
    PowerPoster cafeenman's Avatar
    Join Date
    Mar 2002
    Location
    Florida
    Posts
    2,819

    Turns out program is running so fast that using datetimeserial wasn't giving uniques

    Edit again. It's now in the demo and working properly. I want to use Sleep but it was slowing things down too much so I landed on using a Static variable instead. But I coded the counter (StartCallStackLog Function in cCallStack) in the wrong order so it starts counting at 2 instead of 1. Not a big deal and I fixed it but I'm not uploading it a 4th time just for that fix. Just know that if you try the demo the files start at 2 instead of one. It's an easy fix if you care.

    this is how it should be:

    Code:
    Static nCounter As Long
    
    ' Returns Error Code.
    
    On Error Resume Next
    
    Close #iCallLogFileNum
    
    On Error GoTo errHandler
    
    If DebugMode = idx_Debug_Off Then Exit Function
    
    If nCounter = 99 Then nCounter = 0
    
    nCounter = nCounter + 1
    
    <snip>
    --------------------------------------------

    Edit: This is something new I'm adding. It's not in the demo I uploaded. In the uploaded demo it just merrily keeps on generating file after file with the only limit being drive capacity.
    I decided it's stupid to do it that way because I can't see any reason I'd need to look back at callstacks 10,000 stacks ago.

    --------------------------------------------

    I've spent the last two hours trying to track down a bug in my CallStacker demo.

    I'm using a date/time serial thing I generate to name the files.

    I have a max number of files and when it reaches that max it deletes the oldest file, moves everything up in the array and puts the new file at the end of the array.

    And it starts out fine. For example I have it set to five files.

    So the disk gets five files.

    Then four

    Then two

    then four again

    then three

    I've been tearing my hair out.

    It turns out that it was generating the files so fast (number of calls per file was set to a small number for testing) and it was generating the same file name a couple times in a row.

    I've rewritten the code a dozen times at least trying to figure it out. All the versions of the code worked fine. I could find no problems with it.

    Then I started printing the entire array into the immediate window and that's when I found out that the same file name gets generated several times in succession.

    So I added a static to count and append to the filename and now it works like it should.

    Output *before* appending the static number

    Creating D:\Projects\VB Projects\CallStack Demo\Logs\Call Stacks 20240406002301.txt

    sFilename(0) = D:\Projects\VB Projects\CallStack Demo\Logs\Call Stacks 20240406002258.txt
    sFilename(1) = D:\Projects\VB Projects\CallStack Demo\Logs\Call Stacks 20240406002259.txt
    sFilename(2) = D:\Projects\VB Projects\CallStack Demo\Logs\Call Stacks 20240406002259.txt
    sFilename(3) = D:\Projects\VB Projects\CallStack Demo\Logs\Call Stacks 20240406002300.txt
    sFilename(4) = D:\Projects\VB Projects\CallStack Demo\Logs\Call Stacks 20240406002300.txt


    sFilename(0) = D:\Projects\VB Projects\CallStack Demo\Logs\Call Stacks 20240406002259.txt
    sFilename(1) = D:\Projects\VB Projects\CallStack Demo\Logs\Call Stacks 20240406002259.txt
    sFilename(2) = D:\Projects\VB Projects\CallStack Demo\Logs\Call Stacks 20240406002300.txt
    sFilename(3) = D:\Projects\VB Projects\CallStack Demo\Logs\Call Stacks 20240406002300.txt
    sFilename(4) = D:\Projects\VB Projects\CallStack Demo\Logs\Call Stacks 20240406002301.txt


    Deleted D:\Projects\VB Projects\CallStack Demo\Logs\Call Stacks 20240406002258.txt


    you can see what's going to happen when it gets to 59.

    Output after:

    Creating D:\Projects\VB Projects\CallStack Demo\Logs\Call Stacks 20240406002447_14.txt

    sFilename(0) = D:\Projects\VB Projects\CallStack Demo\Logs\Call Stacks 20240406002445_9.txt
    sFilename(1) = D:\Projects\VB Projects\CallStack Demo\Logs\Call Stacks 20240406002445_10.txt
    sFilename(2) = D:\Projects\VB Projects\CallStack Demo\Logs\Call Stacks 20240406002445_11.txt
    sFilename(3) = D:\Projects\VB Projects\CallStack Demo\Logs\Call Stacks 20240406002446_12.txt
    sFilename(4) = D:\Projects\VB Projects\CallStack Demo\Logs\Call Stacks 20240406002446_13.txt


    sFilename(0) = D:\Projects\VB Projects\CallStack Demo\Logs\Call Stacks 20240406002445_10.txt
    sFilename(1) = D:\Projects\VB Projects\CallStack Demo\Logs\Call Stacks 20240406002445_11.txt
    sFilename(2) = D:\Projects\VB Projects\CallStack Demo\Logs\Call Stacks 20240406002446_12.txt
    sFilename(3) = D:\Projects\VB Projects\CallStack Demo\Logs\Call Stacks 20240406002446_13.txt
    sFilename(4) = D:\Projects\VB Projects\CallStack Demo\Logs\Call Stacks 20240406002447_14.txt


    Deleted D:\Projects\VB Projects\CallStack Demo\Logs\Call Stacks 20240406002445_9.txt

    stuff like this drives me crazy.
    Last edited by cafeenman; Apr 6th, 2024 at 02:35 PM.

Posting Permissions

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



Click Here to Expand Forum to Full Width