Here is a very simple way to log information from your program. It works by setting up a "listener" that will intercept any trace.write
command and send them to the filestream that you open. I use this method to write diagnostic messages.
#USING System.io
#USING System.Diagnostics
FUNCTION Start() AS VOID
LOCAL objTraceListener AS TextWriterTraceListener
LOCAL XferLog AS FileStream
LOCAL cFile AS STRING
cFile := "c:\test.log"
XferLog :=
System.IO.FileStream{System.IO.Path.Combine(System.Environment.CurrentDirectory,
cFile), System.IO.FileMode.Create}
objTraceListener := System.Diagnostics.TextWriterTraceListener{XferLog}
System.Diagnostics.Trace.Listeners:Add(objTraceListener)
Trace.WriteLine("Starting Log")
Trace.WriteLine("This is a test")
Trace.WriteLine("Leaving Log File")
IF (XferLog != NULL)
System.Diagnostics.Trace.Flush()
XferLog:Close()
System.Diagnostics.Trace.Listeners:Remove(objTraceListener)
ENDIF
RETURN
Willie Moore is a ”Professional IT – Network Design” for AT&T located in Birmingham, Alabama. He is also the owner of wmConsulting. He has been programming in Clipper since Summer ’87 and has been producing applications in Visual Objects, Vulcan.net, PHP, VB.net, and C# for the past 20 years He is a Microsoft Certified Systems Engineer and a Microsoft Certified Trainer. Willie can be reached on the Internet at williem@wmConsulting.com.