I have this pretty roughly and badly written piece of code in my app.unhandled exeption event… It will create a text file next to the executable and append errors…
Its copy and pasted and edited by myself from the language reference and various places all over the www…
[code] dim f as new FolderItem( “ErrorDump.txt” )
dim out as TextOutputStream = f.CreateTextFile
dim errmsg as string
dim extension as string
dim heute as new date
dim os as string
dim path as string
if out = nil then return false
'get os
#if TargetMacOS
OS = “Mac OS”
//be more specific of OS Version
dim sys1, sys2, sys3 as Integer
call System.Gestalt("sys1", sys1)
call System.Gestalt("sys2", sys2)
call System.Gestalt("sys3", sys3)
select case sys1
case 10
os = "Mac OSX"
select case sys2
case 0
os = "Mac OSX Chetaah"
case 1
os = "Mac OSX Puma"
case 2
os = "Mac OSX Jaguar"
case 3
os = "Mac OSX Panther"
case 4
os = "Mac OSX Tiger"
case 5
os = "Mac OSX Leopard"
case 6
os = "Mac OSX Snow Leopard"
case 7
os = "Mac OSX Lion"
case 8
os = "Mac OSX Mountain Lion"
case 9
os = "Mac OSX Mavericks"
end select
end select
os = os + " "+str(sys1)+"."+str(sys2)+"."+str(sys3)
#elseif TargetWin32
OS = “Windows”
//try to be more specific of windows version
Soft Declare Sub GetVersionExA lib "Kernel32" ( info as Ptr )
Soft Declare Sub GetVersionExW lib "Kernel32" ( info as Ptr )
dim info as MemoryBlock
if System.IsFunctionAvailable( "GetVersionExW", "Kernel32" ) then
info = new MemoryBlock( 20 + (2 * 128) )
info.Long( 0 ) = info.Size
GetVersionExW( info )
else
info = new MemoryBlock( 148 )
info.Long( 0 ) = info.Size
GetVersionExA( info )
end if
dim str as String
if info.Long( 4 ) = 4 then
if info.Long( 8 ) = 0 then
os = "Windows 95/NT 4.0"
elseif info.Long( 8 ) = 10 then
os = "Windows 98"
elseif info.Long( 8 ) = 90 then
os = "Windows Me"
end if
elseif info.Long( 4 ) = 3 then
os = "Windows NT 3.51"
elseif info.Long( 4 ) = 5 then
if info.Long( 8 ) = 0 then
os = "Windows 2000"
elseif info.Long( 8 ) = 1 then
os = "Windows XP"
elseif info.Long( 8 ) = 2 then
os = "Windows Server 2003"
end if
elseif info.long(4) = 6 then
if info.long(8) = 0 then
os = "Windows Vista"
elseif info.long(8) = 1 then
os = "Windows 7"
end if
end if
str = " Build " + Str( info.Long( 12 ) )
if System.IsFunctionAvailable( "GetVersionExW", "Kernel32" ) then
str = str + " " + Trim( info.WString( 20 ) )
else
str = str + " " + Trim( info.CString( 20 ) )
end if
os = os + str
#elseif TargetLinux
OS = “Linux”
path = “”
#endif
out.WriteLine “System Information:”+EndOfLine
out.WriteLine "Operating System " +os
out.WriteLine "Build# " + str(app.NonReleaseVersion)
out.WriteLine "Build Date "+str(app.BuildDate.SQLDateTime)+EndOfLine
out.WriteLine "UnhandledException: " + Str(error.ErrorNumber) + error.Message + EndOfLine
out.WriteLine "Stack: " + EndOfLine + Join(error.Stack, EndOfLine) + EndOfLine
dim memoryUsed as Integer = Runtime.MemoryUsed
out.WriteLine( “Memory Used: " + Str( memoryUsed ) + " used in heap1” )
dim objCount as Integer = Runtime.ObjectCount
out.WriteLine( Str( objCount ) + " objects" )
Dim i, total as Integer
total=Runtime.ObjectCount
For i=0 to total-1
out.WriteLine Str(Runtime.ObjectID(i)) + " " + Runtime.ObjectClass(i) + " " + Str(Runtime.ObjectRefs(i))
Next
out.Close
print “Sorry, but apparently my programmer seems to be a little stupid, when it comes to exeptions.” + EndOfLine + EndOfLine+ "I have created a dumpfile at " + app.ExecutableFile.parent.AbsolutePath + “ErrorDump.txt” + EndOfLine + endofline+ “Please send it to me”
[/code]