Results 1 to 10 of 10
  1. #1
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 7 64bit Access 2003
    Join Date
    Feb 2011
    Posts
    2,097

    Immediate Window - a point of information

    I spent the better part of 2 hours thinking I had a bug in a newly written app. In the course of pursuit of the bug, I was writing out what I considered telling information via Debug.Print. What I finally discovered was that the "Immediate Window" has a finite capacity for data, at least it seems that is the case. That is, the information written to the Immediate Window during the earlier portion of processing by the app was being over-written by information written later in the process. I verified that the data written earlier was being over-written by suspending execution during the early portion of processing.



    Anyone else experience hitting a limit on the amount of data that can be written to the Immediate Window?

    Bill

  2. #2
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    I do one of two things. If I am looping through a lot of data and each loop has Debug.print, I will count the loops and limit to like 50 or whatever. So the first time around will be the first 50, the second time would be the next 50, and so on.

    The other way is to print it out to a text file. Printing to a text file is tricky because you may have an issue transferring the carriage returns to your text file.

  3. #3
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 7 64bit Access 2003
    Join Date
    Feb 2011
    Posts
    2,097
    I should have included in my original post that my discovery of the limit occurred when I included a debug.assert to stop execution in the earlier portion of the process so I could examine the contents of the Immediate Window.

    And yes, if it were essential to capture EVERYTHING I would have written the debugging information to a text file. Carriage returns aren't a problem if the file is opened with that consideration included.

  4. #4
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    So you are asking questions with ? or as the code ran it was printing to the immediate window and you did not bother to look until assert was false?

    Also, how would you open or create the text file to write to it? I have been using Chr(10) to correct the return within a string. Is it an ANSI standard thing or something?

  5. #5
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,870
    ItsMe,

    I have had several Logger type functions over the years. I use Debug.Print a lot in development/debugging, but I had occassions to write text files for certain apps. Seemed reasonable to create one called Logger that would allow me "unlimited records", since Immediate Window Debug.Print is a fixed size that overwrites ( the subject of this thread).

    Anyway, here is a simple logger function.

    Code:
    '---------------------------------------------------------------------------------------
    ' Procedure : Logger
    ' Author    : jack
    ' Date      : 1/21/2009
    ' Purpose   : To write records to a LOG file using FileSystemObject.
    '
    'Parameters
    ' sLogName As String -- full path and file name of the log file
    ' sLogRec As String  -- record to be written to the log
    '
    ' NOTE: Each log record has a timestamp appended
    '
    ' Special Note/restriction:
    '***** Must set a reference to MICROSOFT SCRIPTING RUNTIME ***
    '
    '****The logfile must exist prior to calling this function *****
    '---------------------------------------------------------------------------------------
    '
    Sub Logger(sLogName As String, sLogRec As String)
    Dim tslog As TextStream
    Dim fileLog As file
    Dim i As Integer
    Dim fso As FileSystemObject
       On Error GoTo Logger_Error
    
    Set fso = New FileSystemObject
    Set fileLog = fso.GetFile(sLogName) '"I:\wordtest\output\Results.log")
    Set tslog = fileLog.OpenAsTextStream(ForAppending)
    tslog.WriteLine Now() & vbTab & sLogRec
    tslog.Close
    
       On Error GoTo 0
       Exit Sub
    
    Logger_Error:
    
        MsgBox "Error " & Err.number & " (" & Err.Description & ") in procedure Logger of Module ADO_Etc"
    End Sub
    Here is a small test routine showing
    -identifying the logfile
    -calling Logger

    Code:
    '---------------------------------------------------------------------------------------
    ' Procedure : testLogger
    ' Author    : Jack
    ' Created   : 4/18/2011
    ' Purpose   : Sample procedure to use the Logger function
    ' Log file must exist before using Logger
    '---------------------------------------------------------------------------------------
    ' Last Modified:
    '
    ' Inputs: N/A
    ' Dependency: N/A
    '------------------------------------------------------------------------------
    '
    Sub testLogger()
    Dim mlog As String
    Dim res As String
       On Error GoTo testLogger_Error
    
    res = "*Pass "
    mlog = "I:/wordtest/output/result_apr2011.txt"
    Dim i As Integer
    For i = 1 To 20
     Call Logger(mlog, res & i)
    Next i
    
       On Error GoTo 0
       Exit Sub
    
    testLogger_Error:
    
        MsgBox "Error " & Err.number & " (" & Err.Description & ") in procedure testLogger of Module ADO_Etc"
    
    End Sub

    I'm sure you've written similar, but thought I would respond to the post since I have seen others asking about writing a simple log.

    I don't know if it's ANSI but carriage return (13), linefeed(10) were record/line terminators in the old days.

  6. #6
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    I was not binding the text file as
    Set tslog = fileLog.OpenAsTextStream(ForAppending)

    So I would employ Chr(10) "line feed". Looking at your example, I am guessing I need to create a TextStream class and use it to write to my file. Thanks Orange!

  7. #7
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 7 64bit Access 2003
    Join Date
    Feb 2011
    Posts
    2,097
    Sorry about any confusion. The only question I was asking was whether anyone else had experienced hitting a data limit in using the Immediate Window, as I never had in the past. My second post was intended to further clarify how it was that I discovered the limit, namely in using the Debug.Assert to suspend execution in order to see that expected data had in fact been written to the Immediate Window but was subsequently over-written.

    I don't use stream to write log files. Rather,

    Code:
    Open IPPath & "\SermonMgr.log" For Append As #1
    Write #1, "============================================================"
    Write #1, Date & " " & Time() & " Sermon Manager started."
    .
    .
    blah blah blah
    .
    .
    Write #1, Date & " " & Time() & " Sermon Mgr Completed."
    Close #1
    Exit Sub

  8. #8
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,870
    Happy to help.
    Good luck.

  9. #9
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    Sorry, I thought the limit thing was a forgone conclusion. Yes, there is a limit.

  10. #10
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,870
    Yes the limit became obvious very early in working with Access.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 3
    Last Post: 05-02-2014, 09:27 AM
  2. Replies: 3
    Last Post: 10-23-2013, 08:11 AM
  3. Can anyone help point me in the right direction?
    By bhamhawker in forum Access
    Replies: 2
    Last Post: 11-04-2012, 08:06 AM
  4. Can someone point to to a tutorial
    By Poker4dbs in forum Forms
    Replies: 8
    Last Post: 08-05-2011, 12:30 PM
  5. What is the point of different modules?
    By cowboy in forum Programming
    Replies: 3
    Last Post: 03-29-2010, 10:43 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
  •  
Other Forums: Microsoft Office Forums