Jump to content

Statistics script for Autoit source code


Recommended Posts

Hi,

I've just started to write some statistic func for Autoit scripts.

Anybody you has some good reg-pattern for collecting the amount of loops?

#include<GUIConstants.au3>

;Varibalen
Global $Source = 0
_collectData()
Exit (0)

$Form1_1 = GUICreate("Statistics", 201, 432, 388, 154)
$Group1 = GUICtrlCreateGroup("", 5, 5, 185, 420)
GUICtrlCreateLabel("Functions", 10, 25, 50, 17)
$Functions_I = GUICtrlCreateInput("0", 95, 20, 86, 21)
GUICtrlCreateLabel("Function calls", 10, 50, 69, 17)
$functionCalls_I = GUICtrlCreateInput("1", 95, 45, 86, 21)
GUICtrlCreateLabel("Includes", 10, 75, 44, 17)
$includes_I = GUICtrlCreateInput("2", 95, 70, 86, 21)
GUICtrlCreateLabel("Lines of code", 10, 100, 68, 17)
$linesOfCode_I = GUICtrlCreateInput("3", 95, 95, 86, 21)
GUICtrlCreateLabel("For Next", 10, 175, 44, 17)
GUICtrlCreateLabel("Loops", 10, 125, 33, 17)
$loops_I = GUICtrlCreateInput("4", 95, 120, 86, 21)
$forNext_I = GUICtrlCreateInput("5", 95, 145, 86, 21)
GUICtrlCreateLabel("While Wend", 10, 150, 63, 17)
$whileWend_I = GUICtrlCreateInput("6", 95, 170, 86, 21)
GUICtrlCreateLabel("Do until", 10, 200, 40, 17)
$doUntil_I = GUICtrlCreateInput("7", 95, 195, 86, 21)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd

Func _collectData()
    If Not ProcessExists('SciTE.exe') Then Exit (0)
    Opt('WinTitleMatchMode', 4)
    WinActivate('classname=SciTEWindow')
    WinWaitActive('classname=SciTEWindow')
    $Source = ControlGetText('classname=SciTEWindow', '', 350)
    ; UDFs
    $re = StringRegExp($Source, 'Func[ ]* [a-zA-Z0-9_]*\(.*\)', 3)
    If Not @error Then ConsoleWrite("Functions found : " & UBound($re) & @CRLF)
    ; Variables
    $re = StringRegExp($Source, '\$[a-z$_0-9A-Z]+', 3)
    $re = _ArrayUnique($re)
    If Not @error Then ConsoleWrite("Variables found : " & UBound($re) & @CRLF)
    ; Includes
    $re = StringRegExp($Source, '(?i)#include[ ]*<[ ]*(.*?\.au3)[ ]*>' , 3)
    If Not @error Then ConsoleWrite("Includes found : " & UBound($re) & @CRLF)
    ; Lines of code
    $re = StringSplit($Source, @CR)
    If Not @error Then ConsoleWrite("Lines of code found : " & UBound($re) - 1 & @CRLF)
    ; Loops For Next
    $re = StringRegExp($Source, '???', 3)
    If Not @error Then ConsoleWrite("For Next found : " & UBound($re) - 1 & @CRLF)
    ; Loops While Wend
    $re = StringRegExp($Source, '???', 3)
    If Not @error Then ConsoleWrite("While Wend found : " & UBound($re) - 1 & @CRLF)
    ; Loops Do until
    $re = StringRegExp($Source, '???', 3)
    If Not @error Then ConsoleWrite("Do until found : " & UBound($re) - 1 & @CRLF)
EndFunc   ;==>_collectData

Func _ArrayUnique(ByRef $aArray, $vDelim = '', $iBase = 1, $iUnique = 1)
    If $vDelim = '' Then $vDelim = Chr(01)
    Local $sHold
    For $iCC = $iBase To UBound($aArray) - 1
        If Not StringInStr($vDelim & $sHold, $vDelim & $aArray[$iCC] & $vDelim, $iUnique) Then _
                $sHold &= $aArray[$iCC] & $vDelim
    Next
    Return StringSplit(StringTrimRight($sHold, StringLen($vDelim)), $vDelim)
EndFunc   ;==>_ArrayUnique

Thanks!

So long,

Mega

Edited by th.meger

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Link to comment
Share on other sites

Hi,

really nobody?

So long,

Mega

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Link to comment
Share on other sites

Improvements to existing:

[Ff][Uu][Nn][Cc][ \t]+[a-zA-Z0-9_]*[ \t]+\(.*\)
(?i)#[ \t]*include[ \t]*[<"][ \t]*(.*?\.au3)[ \t]*[>"]   ;;Spaces are allowed between # and include

#)

Link to comment
Share on other sites

Improvements to existing:

[Ff][Uu][Nn][Cc][ \t]+[a-zA-Z0-9_]*[ \t]+\(.*\)
(?i)#[ \t]*include[ \t]*[<"][ \t]*(.*?\.au3)[ \t]*[>"]  ;;Spaces are allowed between # and include

#)

Hi,

I searched pattern for counting the loops in scripts!

Thanks anyways, I'll have a look at your pattern.

So long,

Mega

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...