Sign in to follow this  
Followers 0
Authenticity

UDFF.au3

3 posts in this topic

#NoTrayIcon

_Main()

Func _Main()
    Local $sAutoIt = @ProgramFilesDir & '\autoit3'
    Local $sAutoItInclude = $sAutoIt & '\include'
    Local $sAutoItSciTE = $sAutoIt & '\scite\api\au3.user.calltips.api'
    
    If FileExists($sAutoItInclude) Then
        $sFiles = FileOpenDialog('User Defined CallTip Format', $sAutoItInclude, 'AutoIt3 (*.au3)', 7)
    Else
        $sFiles = FileOpenDialog('User Defined CallTip Format', '', 'AutoIt3 (*.au3)', 7)
    EndIf
    
    If Not @error Then
        Local $aFiles = StringSplit($sFiles, '|')
        Local $fFile = @error
        Local $sDestination = ''
        
        If Not FileExists($sAutoItSciTE) Then
            $sDestination = FileOpenDialog('Please insert the path to "au3.user.calltips.api"', '', 'api (*.api)', 3)
            
            If Not @error Then
                $sAutoItSciTE = StringReplace($sDestination, '|', '\')
            Else
                Return MsgBox(0x40, 'UDFF (AutoIt v3.3.0.0)', 'No file processed')
            EndIf
        EndIf
        
        If $fFile Then
            _FormatUserCallTip($aFiles[1], $sAutoItSciTE)
        Else
            For $i = 2 To $aFiles[0]
                _FormatUserCallTip($aFiles[1] & '\' & $aFiles[$i], $sAutoItSciTE)
            Next
        EndIf
        $sFiles = StringRegExpReplace($sFiles, '(.*?\|)', '', 1)
        MsgBox(0x40, 'UDFF (AutoIt v3.3.0.0)', 'File(s) processed:' & @LF & @LF  & StringReplace($sFiles, '|', @LF))
    Else
        MsgBox(0x40, 'UDFF (AutoIt v3.3.0.0)', 'No file processed')
    EndIf
EndFunc
        

Func _FormatUserCallTip($sInclude, $sCallTipPath)
    
    Local $aRequired = StringRegExp($sInclude, '.*\\(.*)', 1)
    Local $sRequired = $aRequired[0]
    Local $sFile = FileRead($sInclude)
    Local $sPattern = '(?>;\s*#FUNCTION#[^\r]*\r\n(?:\s*;[^\r]*\r\n)*)'
    Local $aMatches = StringRegExp($sFile, $sPattern, 3)

    If Not IsArray($aMatches) Then Return SetError(1, 0, -1)

    Local $UB = UBound($aMatches)
    Local $sUserCallTip = '', $sDescription, $sFunc_Syntax, $sFuncName
    
    For $i = 0 To $UB-1
        $sFuncName = _SingMatch($aMatches[$i], 'Name[^:]*:\s*([^\r ]*)')
        $sDescription = _SingMatch($aMatches[$i], 'Description[^:]*:\s*([^\r]*)')
        $sFunc_Syntax = _SingMatch($aMatches[$i], 'Syntax[^:]*:\s*(?>[^\r]*)')
        $sFunc_Syntax = StringRegExpReplace($sFunc_Syntax, '(?=\()(\()([^\)]*)(\))', ' $1"$2"$3  ' & $sDescription)
        If Not StringRegExp($sFunc_Syntax, '^' & $sFuncName) Then
            $sFunc_Syntax = StringRegExpReplace($sFunc_Syntax, '(.*?' & $sFuncName & ')', $sFuncName)
        EndIf
        $sUserCallTip &= $sFunc_Syntax & ' (required: #include <' & $sRequired & '>)' & @CRLF
    Next

    If _WriteUDFFFormat($sCallTipPath, $sUserCallTip) Then Return SetError(2, 0, -1)
    Return SetError(0, 0, 0)
EndFunc
    
Func _SingMatch($sStr, $sMatch)
    Local $aMatch = StringRegExp($sStr, $sMatch, 1)
    If IsArray($aMatch) Then Return $aMatch[0]
    Return ''
EndFunc

Func _WriteUDFFFormat($sCallPath, $sCallFormat)
    Local $hFile = FileOpen($sCallPath, 1)
    
    If $hFile = -1 Then Return 1
    FileWrite($hFile, $sCallFormat & @CRLF)
    FileClose($hFile)
    Return 0
EndFunc

I've tried to keep it non-specific as much as possible.

Share this post


Link to post
Share on other sites



Authenticity, this sounds handy, but I wasn't quite able to figure out what's required by the programmer in their UDFs? It doesn't look like it pulls out Funcs.. could you provide the format? Or should I already know :P

Thanks,

Ascend4nt

Share this post


Link to post
Share on other sites

It's a tool not UDF it write CallTips by the conventional format:

_FuncName ("$iParameter, $aParameter") Description goes here (required: #include <filename.au3>)

Share this post


Link to post
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
Sign in to follow this  
Followers 0