Using the TraceFile object
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.
Example: direct access to trace data
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.
|
1 |
string ls_fileName<br>TraceFile ltcf_file<br>TraceActivityNode ltcan_node<br>string ls_line<br> <br>ls_fileName = sle_filename.Text<br>ltcf_file = CREATE TraceFile<br>ltcf_file.Open(ls_fileName)<br>ls_line = "CollectionTime = " + &<br>   String(Truncate(ltcf_file.CollectionTime, 6)) &<br>   + "~r~n" + "Number of Activities = " + &<br>   String(ltcf_file.NumberOfActivities) + "~r~n" + &<br>   "Time Stamp " + "Activity" + "~r~n"<br> <br>mle_output.text = ls_line<br> <br>ltcan_node = ltcf_file.NextActivity()<br>DO WHILE IsValid(ltcan_node)<br>   ls_line += of_dumpActivityNode(ltcan_node)<br>   ltcan_node = ltcf_file.NextActivity()<br>LOOP<br> <br>mle_output.text = ls_line<br>ltcf_file.Close() |
The following code shows part of of_dumpActivityNode:
|
1 |
string lstr_result<br> <br>lstr_result = String(Truncate(atcan_node. &<br>   TimerValue, 6)) + " "<br>CHOOSE CASE atcan_node.ActivityType<br>   CASE ActRoutine!<br>      TraceRoutine ltcrt_routine<br>      ltcrt_routine = atcan_node<br>      IF ltcrt_routine.IsEvent THEN<br>        lstr_result += "Event: "<br>      ELSE<br>        lstr_result += "Function: "<br>      END IF<br>      lstr_result += ltcrt_routine.ClassName + "." + &<br>         ltcrt_routine.name + "(" + &<br>         ltcrt_routine.LibraryName + ") " &<br>         + String(ltcrt_routine.ObjectId) + "~r~n"<br>   CASE ActLine!<br>      TraceLine ltcln_line<br>      ltcln_line = atcan_node<br>      lstr_result += "Line: " +     &<br>         String(ltcln_line.LineNumber) + "~r~n"<br>   CASE ActESQL!   <br>      TraceESQL ltcsql_esql<br>      ltcsql_esql = atcan_node<br>      lstr_result += "ESQL: " + ltcsql_esql.Name &<br>          + "~r~n"<br> <br>   // CASE statements and code omitted<br>   ...<br>   CASE ActBegin!<br>      IF atcan_node.Category = TraceIn! THEN<br>         lstr_result += "Begin Tracing~r~n"<br>      ELSE<br>         lstr_result += "End Tracing~r~n"<br>      END IF<br>   CASE ActGarbageCollect!<br>      lstr_result += "Garbage Collection~r~n"<br>   CASE else<br>      lstr_result += "Unknown Activity~r~n"<br>END CHOOSE<br> <br>RETURN lstr_result |
Document get from Powerbuilder help
Thank you for watching.
Subscribe
Login
0 Comments
Oldest