To access the data in the trace file directly, you create a TraceFile object, open a trace file, and then use the NextActivity function to access each activity in the trace file sequentially. For each node, determine what activity type it is by examining the TraceActivity enumerated datatype, and then use the appropriate trace object to extract information.
The following example creates a TraceFile object, opens a trace file called ltcf_file, and then uses a function called of_dumpActivityNode to report the appropriate information for each activity depending on its activity type.
string ls_fileName TraceFile ltcf_file TraceActivityNode ltcan_node string ls_line ls_fileName = sle_filename.Text ltcf_file = CREATE TraceFile ltcf_file.Open(ls_fileName) ls_line = "CollectionTime = " + & String(Truncate(ltcf_file.CollectionTime, 6)) & + "~r~n" + "Number of Activities = " + & String(ltcf_file.NumberOfActivities) + "~r~n" + & "Time Stamp " + "Activity" + "~r~n" mle_output.text = ls_line ltcan_node = ltcf_file.NextActivity() DO WHILE IsValid(ltcan_node) ls_line += of_dumpActivityNode(ltcan_node) ltcan_node = ltcf_file.NextActivity() LOOP mle_output.text = ls_line ltcf_file.Close()
The following code shows part of of_dumpActivityNode:
string lstr_result
lstr_result = String(Truncate(atcan_node. &
TimerValue, 6)) + " "
CHOOSE CASE atcan_node.ActivityType
CASE ActRoutine!
TraceRoutine ltcrt_routine
ltcrt_routine = atcan_node
IF ltcrt_routine.IsEvent THEN
lstr_result += "Event: "
ELSE
lstr_result += "Function: "
END IF
lstr_result += ltcrt_routine.ClassName + "." + &
ltcrt_routine.name + "(" + &
ltcrt_routine.LibraryName + ") " &
+ String(ltcrt_routine.ObjectId) + "~r~n"
CASE ActLine!
TraceLine ltcln_line
ltcln_line = atcan_node
lstr_result += "Line: " + &
String(ltcln_line.LineNumber) + "~r~n"
CASE ActESQL!
TraceESQL ltcsql_esql
ltcsql_esql = atcan_node
lstr_result += "ESQL: " + ltcsql_esql.Name &
+ "~r~n"
// CASE statements and code omitted
...
CASE ActBegin!
IF atcan_node.Category = TraceIn! THEN
lstr_result += "Begin Tracing~r~n"
ELSE
lstr_result += "End Tracing~r~n"
END IF
CASE ActGarbageCollect!
lstr_result += "Garbage Collection~r~n"
CASE else
lstr_result += "Unknown Activity~r~n"
END CHOOSE
RETURN lstr_result