Want to generate function lists from multiple files

Get help with the installation and running of the Zeus IDE. Please do not post bug reports or feature requests here. When in doubt post your question here.
Post Reply
petervan
Posts: 2
Joined: Tue Jul 18, 2006 3:12 pm

Want to generate function lists from multiple files

Post by petervan »

I'd like to implement a zeus macro to implement the following psudocode idea.

for (each files in all selected directories)
{
generate function list
select all text in the functions window
(ideally echo the name of the file)
append file name and functions list to a document
}

Does anyone have a suggestion.. ?
In general I'd also like to know a scheme for implemnting the following:

for (each files in all selected directories)
{
execute macro
}
jussij
Site Admin
Posts: 2650
Joined: Fri Aug 13, 2004 5:10 pm

Post by jussij »

I think something like this example.vbs macro will do the trick:

Code: Select all

Dim index
' Allocate a big array to hold the functions
Dim all_functions(10000)

Function get_file_functions(strfile)

    ' NOTE: This code would probably work better by running a fgrep
    '       against the file, piping the output to a file and then 
    '       the file back into the all functions array

    ' open the file
    zeus.file_open strFile

    ' find all the functions
    if zeus.FunctionFindAll = 0 then
        all_functions(index) = "No functions found"
        index = index + 1

        ' close the current window
        zeus.FileClose
    else
        ' get the line count for the find files window
        line_count = zeus.get_line_count
        
        ' copy lines to the resutl string
        For current_line = 7 to line_count
            all_functions(index) = zeus.get_line_text (current_line)
            index = index + 1
        Next

        ' close the function window
        zeus.FileClose

        ' close the file window
        zeus.FileClose
    end if

End Function

Function key_macro()
    call zeus.screen_update_disable()

    ' create file open dialog
    Set objDialog = CreateObject("UserAccounts.CommonDialog")
    
    ' set the file filters
    objDialog.Filter = "C++ Files (*.cpp)|*.cpp|All Files|*.*"
    objDialog.FilterIndex = 1

    ' Make the dialog multi-selectable
    objDialog.Flags = &H0200  ' Use older style dialog box

    ' Explorer style multi-select file open dialog does not work
    ' objDialog.Flags = &H80000 + &H4 + &H8 + &H200

    objDialog.InitialDir = "d:\temp"
    intResult = objDialog.ShowOpen

    If intResult = 0 Then
        ' User cancelled operation
    Else

        index = 0
        all_functions(index) = "Function List"
        index = index + 1
        all_functions(index) = "=============\n"
        index = index + 1

        arrFiles = Split(objDialog.FileName, " ")
        For i = 1 to Ubound(arrFiles)
            strFile = arrFiles(0) & arrFiles(i)

            ' add the file to the list
            all_functions(index) = "File: " + strfile
            index = index + 1
    
            ' add the file functions to the list
            get_file_functions strFile

            all_functions(index) = "\n"
            index = index + 1
        Next

        Zeus.FileNew

        for j = 0 to index
            Zeus.write all_functions(j)
            Zeus.write "\n"
        next 
    End If
    call zeus.screen_update_enable()
    call zeus.screen_update()
End Function

key_macro() ' Run the macro
My VB Script is pretty rusty so I am sure there are many ways the script can be improved ;)

Cheers Jussi
petervan
Posts: 2
Joined: Tue Jul 18, 2006 3:12 pm

Post by petervan »

Great thanks.. I'll investigate..

One more quicky.. Do you post documentation/tutorial for the various scripting languages ?

Thanks

Peter
jussij
Site Admin
Posts: 2650
Joined: Fri Aug 13, 2004 5:10 pm

Post by jussij »

Do you post documentation/tutorial for the various scripting languages ?

Since Zeus supports Python, Lua, VB Script, Java Script and Ruby Script just to name a few, unfortunately this is just not practical :(

For scripting documentation I would suggest going to a web page dedicated to the language of you choice. For example links to the Python and Lua web pages can be found on the Zeus macro menu. For VB Script I recommend searching the Microsoft web site.

The Zeus built-in macro functions are covered in the Zeus help (ie search the Zeus help index for the macros keyword) and there are several examples found in the zScript directory or on this forum.

Cheers Jussi
Post Reply