Manfred hat geschrieben:Dein 2.Satz: was meinst Du damit? Das wäre nämlich meine eigentliche Frage gewesen.
das ist wahrscheinlich ein gemeinsames Problem:
Diese STATIC FUNC/PROCs werden meist von einer vorhandenen abgeleitet und vielleicht dann in der anderen STATIC FUNC/PROC etwas verändert. Wenn ich jetzt wieder sowas brauche und diese reinkopiere, erwische ich leicht die falsche oder das Verhalten wird wieder geändert. Am Schluß weiß ich nicht mehr, welche denn nun eigentlich die beste von allen ist.
Da wären wir dann wahrscheinlich bei den Klassen, die gerade an anderer Stelle aktuell angesprochen sind.
Das ist wohl der Punkt, wo auch ich bei CLASS-Code landen sollte. Aber dazu fehlen mir die Grundlagen.
Habe das Programm von Mark mal erweitert.
Es werden jetzt PROCEDURE, FUNCTION, PROC und FUNCT verarbeitet.
Static function oder Static Procedure werden mit einem | versehen.
So kann man unbenutzten Code aufspüren bzw. wenn Static Prozeduren bzw. Functionen und normale gleichen Namens existieren, prüfen was anders ist.
*
* Author Mark J Carew
* 25/10/04 05:18
* Examines
* 1. One prg
* grok myprog.prg
* 2. All Prgs
* grok
* 3. One xpj file's programs
* grok myproj.xpj
* 4. All Prgs in all Xpjs
* grok *.xpj
*
* Create a file - grok.dbf that contains the number of
* times a function that is in the above prg(s) is called
* If hitcount == 0 then the function is ceated but never called
*
#INCLUDE "common.ch"
#INCLUDE "directry.CH"
#INCLUDE "dbfdbe.CH"
#INCLUDE "fileio.CH"
#INCLUDE "deldbe.CH"
/***
*
* FReadLn( <nHandle>, [<nLines>], [<nLineLength>], [<cDelim>] ) --> cLines
*
* Read one or more lines from a text file
*
* NOTES:
* Line length includes delimiter, so max line read is
* (nLineLength - LEN( cDelim ))
*
* Return value includes delimiters, if delimiter was read
*
* nLines defaults to 1, nLineLength to 80 and cDelim to CRLF
*
* FERROR() must be checked to see if FReadLn() was successful
*
* FReadLn() returns "" when EOF is reached
*
*/
STATIC FUNCTION mcTxtLine( nHandle, nLines, nLineLength, cDelim )
LOCAL nCurPos // Current position in file
LOCAL nFileSize // The size of the file
LOCAL nChrsToRead // Number of character to read
LOCAL nChrsRead // Number of characters actually read
LOCAL cBuffer // File read buffer
LOCAL cLines // Return value, the lines read
LOCAL nCount // Counts number of lines read
LOCAL nEOLPos // Position of EOL in cBuffer
DEFAULT nLines TO 1
DEFAULT nLineLength TO 132
DEFAULT cDelim TO ( CHR(13) + CHR(10) )
// Check for error condition
IF !(nChrsRead == nChrsToRead)
// Error!
// In order to stay conceptually compatible with the other
// low-level file functions, force the user to check FERROR()
// (which was set by the FREAD() above) to discover this fact
//
nChrsToRead := 0
ENDIF
// Make sure we don't try to read past EOF
IF (( nFileSize - nCurPos ) < nLineLength )
nChrsToRead := ( nFileSize - nCurPos )
ENDIF
nCount++
ENDDO
RETURN ( cLines )
/***
*
* FilePos( <nHandle> ) --> nPos
*
* Report the current position of the file pointer in a binary file
*
*/
STATIC FUNCTION FilePos( nHandle )
RETURN ( FSEEK( nHandle, 0, FS_RELATIVE ) )
/***
*
* FileSize( <nHandle> ) --> nBytes
*
* Return the size of a binary file
*
*/
STATIC FUNCTION FileSize( nHandle )
LOCAL nCurrent
LOCAL nLength
// Get file position
nCurrent := FilePos( nHandle )
Nur der Vollständigkeit halber: Symbolinfo(DEFINE) liefert Arrays, die - je nach DEFINE - alle PRIVATES, PUBLICS, auf Wunsch aber auch alle Funktionen/Prozeduren, Klassendeklarationen usw. auflistet.