473,418 Members | 2,121 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,418 software developers and data experts.

Leaving debug.print statements in a database intended for runtime?

MLH
I use a fair number of debug.print statements. My apps are
fairly well 'peppered' with them. I've often wondered if leaving
them in the mdb, creating and rolling out an mde intended for
use in the A97 runtime environment might ever be cause for
concern. I've noticed no symptoms to indicate a problem. Are
there drawbacks to this practice?
Dec 13 '05 #1
5 2818
MLH wrote:
I use a fair number of debug.print statements. My apps are
fairly well 'peppered' with them. I've often wondered if leaving
them in the mdb, creating and rolling out an mde intended for
use in the A97 runtime environment might ever be cause for
concern. I've noticed no symptoms to indicate a problem. Are
there drawbacks to this practice?


I asked a similar uestion a while ago and I believe the consensus was no
real effects. However, for development, the debug window is a valuable
tool and I prefer to turn these off as much as I can so as not to have
too cluttered a debug screen when I need it. A simple mdb wide find and
replace debug.print wit 'debug.print suffices, though you'll end up with
a number of '''''''''debu.prints. No matter, when you need it for
development purposes, you can remove the comment character.

--
Tim http://www.ucs.mun.ca/~tmarshal/
^o<
/#) "Burp-beep, burp-beep, burp-beep?" - Quaker Jake
/^^ "Whatcha doin?" - Ditto "TIM-MAY!!" - Me
Dec 13 '05 #2
MLH <CR**@NorthState.net> wrote in
news:qn********************************@4ax.com:
I use a fair number of debug.print statements. My apps are
fairly well 'peppered' with them. I've often wondered if leaving
them in the mdb, creating and rolling out an mde intended for
use in the A97 runtime environment might ever be cause for
concern. I've noticed no symptoms to indicate a problem. Are
there drawbacks to this practice?


It could conceivably be a minor performance drain, but otherwise not
a big deal.

If you care about this kind of thing, you could create a subroutine
to call Debug.Print that checks if you're running in the runtime. I
don't know the actual command for that, but I know it exists. Your
function would take a string argument and could be something like
this:

Public Sub PrintDebug(strOutput As String)
' check for runtime however it's done
If [is runtime] Then Exit Sub
Debug.Print strOutput
End Sub

Then you could do a search and replaces on all your "Debug.Print"
statements with "PrintDebug" (except, of course, the one in the
PrintDebug() subroutine).

--
David W. Fenton http://www.bway.net/~dfenton
dfenton at bway dot net http://www.bway.net/~dfassoc
Dec 13 '05 #3
MLH <CR**@NorthState.net> wrote in
news:qn********************************@4ax.com:
I use a fair number of debug.print statements. My apps are
fairly well 'peppered' with them. I've often wondered if leaving
them in the mdb, creating and rolling out an mde intended for
use in the A97 runtime environment might ever be cause for
concern. I've noticed no symptoms to indicate a problem. Are
there drawbacks to this practice?


Oh, one thing I meant to include in my post about creating a
subroutine to do Debug.Print statements:

Don't check for the runtime every time. Instead, use a static
variable and check that it's been initialized and look it up only if
it hasn't been. That means you can't use a Boolean variable.

Static intIsRuntime As Integer

If intIsRuntime = 0 Then
If [isruntime] Then
intIsRuntime = -1
Else
intIsRuntime = 2
End If
End If

Then you'd check to see if intIsRuntime = -1 before printing your
debug statements.

--
David W. Fenton http://www.bway.net/~dfenton
dfenton at bway dot net http://www.bway.net/~dfassoc
Dec 13 '05 #4
Br
David W. Fenton wrote:
MLH <CR**@NorthState.net> wrote in
news:qn********************************@4ax.com:
I use a fair number of debug.print statements. My apps are
fairly well 'peppered' with them. I've often wondered if leaving
them in the mdb, creating and rolling out an mde intended for
use in the A97 runtime environment might ever be cause for
concern. I've noticed no symptoms to indicate a problem. Are
there drawbacks to this practice?


It could conceivably be a minor performance drain, but otherwise not
a big deal.

If you care about this kind of thing, you could create a subroutine
to call Debug.Print that checks if you're running in the runtime. I
don't know the actual command for that, but I know it exists. Your
function would take a string argument and could be something like
this:

Public Sub PrintDebug(strOutput As String)
' check for runtime however it's done
If [is runtime] Then Exit Sub
Debug.Print strOutput
End Sub

Then you could do a search and replaces on all your "Debug.Print"
statements with "PrintDebug" (except, of course, the one in the
PrintDebug() subroutine).


Another solution may be to check the current user (either Windows or
Workgroup) and conditionally run the code.

eg.

Function MyDebug(pObject as String, pValue as Variant)
If CurrentUser()="developer" Then
Debug.Print pObject & " = " & pValue
End If
End If

Or another may be to check for a command-line argument (ie. you'd call
your app up using a shortcut with a specific arguement)

eg.

Shortcut:

"C:\Program Files\Microsoft Office\Office\MSACCESS.EXE"
"C:\BIGCare\BigCare.mde" /wrkgrp "C:\BIGCare\Data\BigCare.mdw" /cmd
"developer"

Function MyDebug(pObject as String, pValue as Variant)
If Command()="developer" Then
Debug.Print pObject & " = " & pValue
End If
End If

--
regards,

Bradley

A Christian Response
http://www.pastornet.net.au/response
Dec 13 '05 #5
I've taken to using this solution for combined debugging and error handling.

In a module:

Public Const BCONN = "Connecting to server"
Public Const BCLOSE = "Closing connection"
Public Const BSAVES = "Saving to server"
Public Const BSAVEL = "Saving locally"
Public Const BUPD = "Updating form"
Public Const BEXES = "Executing on server"
Public Const BEXEL = "Executing on server"

Private errorText As String
'--------------
Public Sub Bug(commentString As String)
errorText = commentString
SysCmd acSysCmdSetStatus, commentString
End Sub
'--------------
Public Sub NoBug()
DoCmd.Hourglass False
errorText = vbNullString
SysCmd acSysCmdClearStatus
End Sub
'--------------
Public Function GetBug() As String
GetBug = errorText
End Function
'--------------
Public Sub LogError(errLoc As String, errDesc As String, Optional messageBox
= True)
On Error GoTo handle_error
' The next two lines are because I want the ID of the offender record, and
' have found the error numbers usually useless

Dim errNo As Long
errNo = Nz(GetOffender_ID(), 0)

If StrComp(GetBug(), BCONN, vbTextCompare) = 0 Then
errDesc = BCONN
Else
errDesc = Left(Left(errDesc, 150) & (" " + GetBug()), 255)
End If
DoCmd.Hourglass True

Dim cnxn As ADODB.Connection
Set cnxn = New ADODB.Connection
With cnxn
SysCmd acSysCmdSetStatus, BCONN
.Provider = "Microsoft.Jet.OLEDB.4.0"
.Open "Data Source=" & GetServer()

SysCmd acSysCmdSetStatus, "Logging error"
.Execute "INSERT INTO db_error_log (err_number, err_location,
err_desc, err_user, err_time)" & _
"VALUES (" & errNo & ", " & S2SQL(errLoc) & ", " & _
S2SQL(errDesc) & ", " & S2SQL(GetUserLogin()) & ", #" &
Now() & "#)"

SysCmd acSysCmdSetStatus, BCLOSE
.Close
End With

DoCmd.Hourglass False
DoCmd.Echo True
SysCmd acSysCmdClearStatus
If messageBox Then
If StrComp(GetBug(), BCONN, vbTextCompare) = 0 Then
MsgBox "The server was busy. Please try the operation again.",
vbOKOnly, "Server Busy"
Else
MsgBox "The following error: [" & errDesc & _
"] was generated from module: " & _
errLoc, vbOKOnly, "Error: " & errNo
End If
End If
Exit Sub
handle_error:
DoCmd.Hourglass False
MsgBox "Unable to write data to the server. " & _
"Errors are not being reported. Please contact " & _
"the system administrator and report this error." & _
"Highest priority.", vbCritical, "Critical Error!"
' Application Quit
End Sub
'-------------------------

In production, the Bug() statement can easily be changed to not echo to the
status bar.

A typical function then has no comments, just Bug() statements:
Private Sub btnSave_Click()
On Error GoTo handle_error
DoCmd.Hourglass True

Dim cnxn As ADODB.Connection
Dim rS As ADODB.Recordset
Set cnxn = New ADODB.Connection
Set rS = New ADODB.Recordset

Bug (BCONN)
cnxn.Provider = "Microsoft.Jet.OLEDB.4.0"
cnxn.Open "Data Source=" & GetServer()

Bug (BSAVES)
With rS
.Source = "SELECT * FROM current_sup WHERE cs_off_id=" & _
Me!txtOffID.Value
.Open , cnxn, adOpenKeyset, adLockOptimistic, adCmdText
.Fields("cs_pda_notes") = Me!txtNotes.Value
.Fields("updated") = Now()
.Fields("update_by") = GetUserLogin()
.Update
.Close
End With

Bug (BCLOSE)
cnxn.Close

Bug ("Updating list")
CurrentProject.Connection.Execute "UPDATE HomeCaseloadTable SET Notes = "
& _
S2SQL(Me!txtNotes.Value) & " WHERE Vaccis=" &
Me!txtOffID.Value, , adCmdText

NoBug
DoCmd.Close acForm, Me.Name
Forms("HomeForm")!lstCaseload.Requery
Exit Sub
handle_error:
LogError "GoCaseloadForm.btnSave", Err.Description
End Sub

--
Darryl Kerkeslager
Dec 14 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Manfred Schwab | last post by:
Recording messages and print statements in a textfile during program execution. Is there a similar command to redirect errormessages or print statements into a standart asciifile during...
9
by: Dan Perl | last post by:
Is there a mechanism or an idiom for adding code for debugging so that it can easily be removed in the production code? I am thinking of something similar to the C/C++ preprocessor statements with...
1
by: Robert | last post by:
Simple way of writing debug print statements in your JavaScript code. You need to have enabled popups in your browser. I liked the ability to write to the java console in Netscape 4.x. This,...
3
by: Tim Marshall | last post by:
For an mdb or mde release, does having debug.print without the comment single quote add any processing time to the application? I assume an mde won't since debug.prints would not be compiled in...
10
by: Scott | last post by:
I have a simple asp.net app which works fine in debug mode, but crashes on the following line when I run it on the production server: Dim dt As DataTable I have tried the following variations...
6
by: pauldepstein | last post by:
To help me debug, I am writing a lot of information into a stream which I call debug. However, because of the large amount of time taken to print this information, I only want this printed while...
2
by: Bill_DBA | last post by:
I have the following stored procedure that is called from the source of a transformation in a DTS package. The first parameter turns on PRINT debug messages. The second, when equals 1, turns on the...
15
by: Jim B. Wilson | last post by:
Am I nuts? Or only profoundly confused? I expected the this little script to print "0": class foo(int): def __init__(self, value): self = value & 0xF print foo(0x10) Instead, it prints...
7
by: =?Utf-8?B?SmltIFdhbHNo?= | last post by:
I'm new to working with mixed assemblies. All of my previous experience has been with VC++/MFC in native, unmanaged applications. When I create a mixed assembly in which one or more of the files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.