TGC Codebase Backup



List functions to Text file as Overview by Markus

31st Jan 2013 13:53
Summary

List the functions from selected .agc files.



Description

make a function list file with row count.
Open a file dialog and copy the .agc file to media/ (automatic)
then parsing for function in this file
until cancel in choose file dialog.
then it open a browser and you can click the text file with overview.



Code
                                    ` This code was downloaded from The Game Creators
                                    ` It is reproduced here with full permission
                                    ` http://www.thegamecreators.com
                                    
                                    rem
rem AGK Application 1.08B8
rem

// MR 31.01.2013.1
// 0815 FunctionList from .agc files

//Use AGK Strg+G for goto to a row number in a open file

fout=opentowrite("FunctionListAGK.txt",0) // > \media\FunctionListAGK.txt
writeline(fout,getcurrentdate()+" "+getcurrenttime())
writeline(fout,"Strg+G in the AGK IDE = Goto line ....")
writeline(fout,"")

do
    //this will copy the file to the app media path!
    file$=Chooserawfile("*.agc") // die Datei landet dann im Media Ordner bei C:\Users\User\Documents\AGK\FunctionList\media\ ^^
    if len(file$)=0 then exit
    SearchFunctions(file$,fout)
    deletefile(file$) // its a copy
loop

closefile(fout)

//open the default web browser
OpenBrowser("file:///"+GetwritePath()+"media/")

end

function SearchFunctions(file$,fout)

    // Open the File and then read each line and look for a beginning "function ", then write to output text file as overview list

    if right(file$,4)=".agc"

        fc=opentoread(file$)
        writeline(fout,"-------------------------------------------")
        writeline(fout,file$)
        writeline(fout,"-------------------------------------------")

        c=0
        do
            if fileeof(fc) then exit
            c=c+1
            l$=readline(fc)
            if lower(left(l$,9)) = "function "
                output$=str(c) +" "+ mid(l$,9,len(l$)-8)
                writeline(fout,output$)
            endif
        loop

        closefile(fc)

    else
        output$="skip file "+file$
        writeline(fout,output$)
    endif

endfunction