Functionen auslesen aus Hauptfile + all Includes

Übersicht BlitzBasic Codearchiv

Neue Antwort erstellen

 

c64

Betreff: Functionen auslesen aus Hauptfile + all Includes

BeitragSa, Sep 23, 2006 18:18
Antworten mit Zitat
Benutzer-Profile anzeigen
Hi,

Da ich bisher nix wirklich vernünftiges gefunden habe das auch alle Includefiles berücksichtigt habe ich mir selber schnell was geschrieben.

Momentan geht es nur mit BB files, jedenfalls bei mir. Wenn die BMX files nicht zu stark verzweigt sind geht es unter Umständen auch mit Bmx files.

Entweder über Commandline einen File angeben oder in Mainfile$ eintragen.

Es wird ein Logfile erstellt und im Notepad ausgegeben wenn keine Fehler auftraten.

Damit lassen sich bei gegebener Formatierung auch schön Decl's erstellen.

Eine Gui wollte ( / brauchte) ich momentan nicht, reicht erstmal so das es functioniert.

Bitte testet es mal wenn ihr möchtet und Postet Bugs falls welche kommen Danke.

mfg C64.

Filename : "Get_funcs_v12a.bb"

Code: [AUSKLAPPEN]

;///////////////////////////////////////////////////////////////////////////
;/
;/ File Parser V1.12a
;/
;/ Get all Functions from a Mainfile and Includes
;/
;///////////////////////////////////////////////////////////////////////////

;Graphics 500,20,0,2

; hwnd=api_GetActiveWindow ( )
;      api_ShowWindow (hwnd,0)
         

Global   curdir$=CurrentDir()

   Global Mainfile$

          Mainfile$="Get_funcs_v12a.bb" ; <--------- ADD YOUR FILENAME HERE
            

Global  path$
Global Tpath$
      
Global fndd_funcs
Global fndd_files
Global Lfile = WriteFile ("log.txt")


;///////////////////////////////////////////////////////////////////////////
;/
;/
;/  ALL what the Programm does stand here.
;/

   start=MilliSecs() 
   ReadIN       (MAINFILE$)
   time =MilliSecs()-start

   ChangeDir     CURDIR
   CloseFile     LFILE
         
   ExecFile     "notepad log.txt"
   
   RuntimeError "READY"+Chr(13)+ FNDD_FUNCS +" founded functions in "+fndd_files+" files  / @time :"+time*.001+" sek"

   
;/
;/
;/
;///////////////////////////////////////////////////////////////////////////

Global file.tfile

Type Tfile
   
    Field Name$
   
End Type


Function Add_file(FName$)
             
        Print "    FILE : " + FName$
   
       fndd_files=fndd_files+1
      
       file       = New Tfile
       file\name = FName
      
End Function

;///////////////////////////////////////////////////////////////////////////

Global FUNCS.TFUNCS

Type TFUNCS
   
    Field txt$
    Field in_file
   
End Type

Function Add_function(txt$)

               fndd_funcs = fndd_funcs + 1
       Print "Function :<" + fndd_funcs + ">  "+txt
      
                                          
       FUNCS         = New TFUNCS
       FUNCS\txt     = txt
       FUNCS\in_file = Handle (File)
      
End Function

;///////////////////////////////////////////////////////////////////////////

;///////////////////////////////////////////////////////////////////////////

Function ReadIN    (   FNAME$ )

  path   =getpath$ ( mainfile )



  add_FILE         (   FNAME$ )

  readin_files     (   FNAME$ )

  readin_functions (          )

End Function

;///////////////////////////////////////////////////////////////////////////

Function ReadIn_files (Fname$)

           RFILE   = OpenFile (Fname$)
   
   
          
          While Not Eof (RFile)
              
          file_name$ = Upper(Parse (ReadLine(RFILE))   )                           
         
          file_name  = Upper(Replace (file_name,"/","\"))
         
                If file_name$ <> ""
         
                     add_FILE   file_name
         
                   Readin_files (file_name$)
               
                  EndIf        

          Wend
   
          
           CloseFile RFILE

         
End Function

;///////////////////////////////////////////////////////////////////////////

Function ReadIn_Functions ()

      For file=Each Tfile

        RFILE = OpenFile (file\name)
      
             Print ""
             Print ""
             Print "//"+Replace(RSet("",Len(FILE\NAME))," ","/")
             Print "/"
             Print "/ "+File\NAME
             Print "/"
             Print "/ "+Replace(RSet("",Len(FILE\NAME))," ","-")
             Print ""
             Print ""
            
              While Not Eof (RFile)
   
               
                   func_name$ = Parse (ReadLine(RFILE),1)                              
         
                     If Instr (func_name,"(") <> 0 And Instr (func_name,")") <> 0
               
                          If func_name$ <> ""
         
                          add_function func_name
       
                        EndIf        
         
                   EndIf        
         

              Wend
         
              Print ""
              Print "/"
              Print "/"
              Print "/"
             Print "//"+Replace(RSet("",Len(FILE\NAME))," ","/")
              Print ""
              Print "-------------------------------------------------------------------------------"
                  
         CloseFile RFILE
      
       Next
      
End Function

;///////////////////////////////////////////////////////////////////////////

Function GetPath$ (FILE$)

             rtn$=CurDIR
      
       For c=1 To Len (file)-1
      
          If Mid(FILE,c,1)="\" Or Mid(FILE,c,1)="/" pos=c
      
       Next
      
       If pos > 0
               
         rtn= Mid (File,1,pos)      
      
       EndIf

         
         rtn = Upper(RTN)

          Print "MAINPATH :" +rtn
         
         ChangeDir RTN
         
             Return        rtn
      
End Function

;///////////////////////////////////////////////////////////////////////////

Function Parse$ (txt$,what=0)
   
            txt=Lower(txt)
            
       Select what
      
      
      
            Case 0 ; FILES
            
              chk = Instr (txt,"include")
            
              If chk > 0
            
                pos  = Instr (txt,Chr(34)      )
               
                If pos < chk Return
               
                 pos2 = Instr (txt,Chr(34),  pos+1) - pos-1
            

               
            
                If pos2 > 1 And pos > 0
               
                     fileName$=Mid$(txt,pos+1,pos2)
         
                   If path And Instr(filename$,path)=0 filename = path+filename
               
                Return filename
               
                 EndIf
            
              EndIf
         
         
         
         
            
            Case 1 ; Functions
            
                 chk = Instr (txt,"function ")
            
              If chk > 0
            
                pos  = Instr (txt,")"     )
               
                Func_name$=Trim (Mid(txt,chk+8,pos-8))
            
                  Return func_name
                  
              EndIf
      
       End Select       
   
End Function



;//////////////////////////////////////

Function Print(txt$)
DebugLog txt
WriteLine lfile,txt
End Function

;//////////////////////////////////////

StepTiger

BeitragSa, Sep 23, 2006 19:15
Antworten mit Zitat
Benutzer-Profile anzeigen
könnte man sowas also in richtung CS Console machen oder wie?
Noch gestern standen wir am Abgrund, doch heute sind wir schon einen Schritt weiter.
Computer:
AMD Sempron 3000+; ATI Radeon 9800 Pro; 512 MB DDR RAM 400Mhz; Asus E7N8X-E Deluxe; Samsung 200GB HD 5.4ns acces t
Gewinner: BP Code Compo #2
Π=3.141592653589793238...<--- und das aus dem kopf Laughing
Seit der Earthlings-Diskussion überzeugter Fleisch(fr)esser.
 

c64

BeitragSa, Sep 23, 2006 20:14
Antworten mit Zitat
Benutzer-Profile anzeigen
Console, Gui, eigentlich alles. Denn es wird ja in 2 Listen gespeichert einmal die Files und einmal die Functionen und die Functionen haben noch die Info aus welchem File sie kommen.
Betreten verboten! Kinder haften für ihre Eltern!

Neue Antwort erstellen


Übersicht BlitzBasic Codearchiv

Gehe zu:

Powered by phpBB © 2001 - 2006, phpBB Group