$PBExportHeader$n_linectr.sru $PBExportComments$Datastore that holds results of line count forward global type n_linectr from datastore end type end forward global type n_linectr from datastore string dataobject = "d_linectr_detail" end type global n_linectr n_linectr forward prototypes public function integer of_count_lines (string as_source) public subroutine of_nestedclass (ref classdefinition acd_object, string as_libname, string as_objname, string as_objtype) public subroutine of_count (boolean ab_sql_only, boolean ab_structural) public function libexporttype of_getexporttype (string as_objtype) end prototypes public function integer of_count_lines (string as_source);// count the number of lines in passed source code Long ll_pos Integer li_cnt If Len(as_source) = 0 Then Return 0 ll_pos = Pos(as_source, "~r~n", 1) DO WHILE ll_pos > 0 li_cnt = li_cnt + 1 ll_pos = Pos(as_source, "~r~n", ll_pos + 1) LOOP Return li_cnt end function public subroutine of_nestedclass (ref classdefinition acd_object, string as_libname, string as_objname, string as_objtype);ClassDefinition lcd_nestedclass String ls_event, ls_name, ls_msg Integer li_cnt, li_max, li_lines Long ll_newrow // analyze class events li_max = UpperBound(acd_object.ScriptList) FOR li_cnt = 1 TO li_max ls_name = acd_object.Name // check for scripts at this level If acd_object.ScriptList[li_cnt].IsLocallyScripted Then ls_event = acd_object.ScriptList[li_cnt].Name If ls_event = "create" Or ls_event = "destroy" Then // ignore create/destroy events, they are not coded by programmer Else // build the name of the script If ls_name = as_objname Then If acd_object.ScriptList[li_cnt].Kind = ScriptFunction! Then ls_name = "function " + ls_event Else ls_name = "event " + ls_event End If Else ls_name = ls_name + "::" + ls_event End If // get the line count for this script li_lines = this.of_count_lines(acd_object.ScriptList[li_cnt].Source) - 1 // insert row into resultset If li_lines > 0 Then ll_newrow = this.InsertRow(0) this.SetItem(ll_newrow, "libname", as_libname) this.SetItem(ll_newrow, "objtype", as_objtype) this.SetItem(ll_newrow, "objname", as_objname) this.SetItem(ll_newrow, "script", ls_name) this.SetItem(ll_newrow, "lines", li_lines) End If End If End If NEXT // analyze nested classes li_max = UpperBound(acd_object.NestedClassList) FOR li_cnt = 1 TO li_max lcd_nestedclass = acd_object.NestedClassList[li_cnt] // ignore object structures, a bug in pb causes stack fault If lcd_nestedclass.DataTypeOf <> "structure" Then this.of_nestedclass(lcd_nestedclass, as_libname, as_objname, as_objtype) End If NEXT end subroutine public subroutine of_count (boolean ab_sql_only, boolean ab_structural);ClassDefinition lcd_object DataStore lds_dwsql Long ll_row, ll_max, ll_newrow Integer li_pct, li_lines, li_rc String ls_libname, ls_objname, ls_objtype String ls_object, ls_source, ls_msg this.Reset() lds_dwsql = CREATE DataStore ll_max = gn_dir.RowCount() FOR ll_row = 1 TO ll_max Yield() SetPointer(HourGlass!) li_pct = (ll_row / ll_max) * 100 gw_frame.SetMicroHelp("Percent Complete: " + String(li_pct)) ls_libname = gn_dir.GetItemString(ll_row, "libname") ls_objname = gn_dir.GetItemString(ll_row, "objname") ls_objtype = gn_dir.GetItemString(ll_row, "objtype") // analyze the object If ls_objtype = "datawindow" Then // extract source from the library ls_object = LibraryExport(ls_libname, ls_objname, ExportDataWindow!) If ab_SQL_only Then // create datawindow into datastore li_rc = lds_dwsql.Create(ls_object, ls_msg) If li_rc = -1 Then MessageBox("Datawindow Create Error", ls_msg, StopSign!) Return End If ls_source = lds_dwsql.GetSQLSelect() // get the line count for this sql statement li_lines = this.of_count_lines(ls_source) If li_lines = 0 Then li_lines = Integer(lds_dwsql.Object.DataWindow.Column.Count) Else li_lines = li_lines + 1 End If Else li_lines = this.of_count_lines(ls_object) End If // insert row into resultset ll_newrow = this.InsertRow(0) this.SetItem(ll_newrow, "libname", ls_libname) this.SetItem(ll_newrow, "objtype", ls_objtype) this.SetItem(ll_newrow, "objname", ls_objname) this.SetItem(ll_newrow, "script", "datawindow sql") this.SetItem(ll_newrow, "lines", li_lines) Else If ab_structural Then // extract source from the library ls_object = LibraryExport(ls_libname, ls_objname, of_GetExportType(ls_objtype)) li_lines = this.of_count_lines(ls_object) // insert row into resultset ll_newrow = this.InsertRow(0) this.SetItem(ll_newrow, "libname", ls_libname) this.SetItem(ll_newrow, "objtype", ls_objtype) this.SetItem(ll_newrow, "objname", ls_objname) this.SetItem(ll_newrow, "script", "edit source") this.SetItem(ll_newrow, "lines", li_lines) Else // get class definition lcd_object = FindClassDefinition(ls_objname, gs_libnames) If IsNull(lcd_object) Then ls_msg = ls_objtype + " object " + ls_objname + " in library " + ls_libname MessageBox("FindClassDefinition Failed", ls_msg) Else // analyze the class this.of_nestedclass(lcd_object, ls_libname, ls_objname, ls_objtype) End If End If End If NEXT DESTROY lds_dwsql gw_frame.SetMicroHelp("Ready") end subroutine public function libexporttype of_getexporttype (string as_objtype);// ----------------------------------------------------------------------------- // FUNCTION: of_GetExportType // // PURPOSE: This function returns the LibExportType enumeration for // the object type or extension. // // ARGUMENTS: as_objtype - Object type // // RETURN: LibDirType // // DATE PROG/ID DESCRIPTION OF CHANGE / REASON // ---------- -------- ----------------------------------------------------- // 02/07/2019 RolandS Initial coding // ----------------------------------------------------------------------------- LibExportType l_type choose case Lower(as_objtype) case "sra", "application" l_type = ExportApplication! case "srd", "datawindow" l_type = ExportDataWindow! case "srf", "function" l_type = ExportFunction! case "srm", "menu" l_type = ExportMenu! case "srp", "pipeline" l_type = ExportPipeline! case "srj", "project" l_type = ExportProject! case "srq", "query" l_type = ExportQuery! case "srs", "structure" l_type = ExportStructure! case "sru", "userobject" l_type = ExportUserObject! case "srw", "window" l_type = ExportWindow! end choose Return l_type end function on n_linectr.create call super::create TriggerEvent( this, "constructor" ) end on on n_linectr.destroy TriggerEvent( this, "destructor" ) call super::destroy end on
File: n_linectr.sru
Size: 6964
Date: Wed, 17 Mar 2021 01:54:08 +0100
Size: 6964
Date: Wed, 17 Mar 2021 01:54:08 +0100
- datastore n_linectr(sru)