No he analizado el tema de las bibliotecas de clase, cosa que no es menor. Pero al menos para dar una idea.
El procedimiento toma todos los archivos, entre los que pueden existir residuos que han sido descartados.
*************************************************
PROCEDURE Raconto(xcDapli,xcDtemp)
**************************************************
* xcDapli: Directorio de la aplicación
* xcDtemp: Directorio de trabajo (si no se define, toma xcDapli)
* Supone que los procedimientos están en "\PROGS"
* Supone que los Formularios están en "\forms"
LOCAL nFiles,lnLineas
IF VARTYPE(xcDapli)#"C".or.empty(xcDapli)
MESSAGEBOX("Indique la carpeta base",0,"Raconto")
RETURN
ENDIF
IF !DIRECTORY(xcDapli)
MESSAGEBOX("La carpeta &xcDapli no existe!",0,"Raconto")
RETURN
ENDIF
if vartype(xcDtemp)#"C".or.empty(xcDtemp)
xcdtemp=xcdapli
endif
lcDirProg=ADDBS(xcDapli)+"PROGS"
lcDirForm=ADDBS(xcDapli)+"FORMS"
IF !DIRECTORY(lcDirProg)
MESSAGEBOX("No existe la carpeta &lcDirProg",0,"Raconto")
RETURN
ENDIF
IF !DIRECTORY(lcDirForm)
MESSAGEBOX("No existe la carpeta &lcDirForm",0,"Raconto")
RETURN
ENDIF
nMax=0
RELEASE GACLAVE
PUBLIC ARRAY gaclave(4,3)
gaclave[1,1]="PROCEDURE"
gaclave[1,2]=.t.
gaclave[2,1]="FUNCTION"
gaclave[2,2]=.t.
gaClave[3,1]="ENDPROC"
gaclave[4,1]="ENDFUNC"
FOR i=1 TO ALEN(gaclave,1)
GACLAVE[i,3]=0
NEXT
PUBLIC omens
oMens=CREATEOBJECT("Form")
IF VARTYPE(omens)="O"
WITH omens
.Width=680
.Height=360
.top=40
.Left=50
.BackColor=RGB(255,255,255)
.ForeColor=RGB(0,0,0)
.FontName="Arial"
.FontSize=8
.Caption="Raconto"
.Visible=.t.
.Show()
ENDWITH
endif
nSto=0
LOCAL ARRAY gastore(1,4)
nFiles=ADIR(gaFiles,ADDBS(LcdirProg)+"*.prg")
IF nFiles>0
omens.Caption="Recorriendo Procedimientos Prg"
FOR i=1 TO ALEN(gafiles,1)
IF LEN(gafiles[i,1])>nMax
nMax=LEN(gafiles[i,1])
endif
gafiles[i,2]=0
gafiles[i,3]=0
gafiles[i,4]=0
next
FOR si=1 TO ALEN(gafiles,1)
nfop=-1
IF !GEtfopen(gafiles[si,1],@nfop)
LOOP
ENDIF
* WAIT WINDOW "Archivo de Procedimientos "+gafiles[si] AT 12,15 nowait
? " Archivo de Procedimientos "+gafiles[si,1]
Racontext(NFOP)
NEXT
bi=ALEN(gafiles,2)
FOR i=1 TO ALEN(gafiles,1)
nSto=nSto+1
DIMENSION gastore(nSto,bi)
FOR j=1 TO ALEN(gafiles,2)
gastore[nsto,j]=gafiles[i,j]
NEXT
NEXT
ENDIF
* Formularios
RELEASE gafiles
cNametod=addbs(xcDtemp)+"gMetod.txt"
nFiles=ADIR(gaFiles,ADDBS(LcdirForm)+"*.scx")
IF nFiles>0
* WAIT WINDOW "Recorriendo Formularios..." AT 12,15 nowait
omens.Caption="Recorriendo Formularios..."
FOR i=1 TO ALEN(gafiles,1)
IF LEN(gafiles[i,1])>nMax
nMax=LEN(gafiles[i,1])
endif
gafiles[i,2]=0
gafiles[i,3]=0
gafiles[i,4]=0
NEXT
FOR si=1 TO ALEN(gafiles,1)
lcFormu=ADDBS(lcDirForm)+gafiles[si,1]
* WAIT WINDOW "Analizando &lcFormu..." AT 12,15 nowait
? " Analizando &lcFormu..."
SELECT 0
USE (lcFormu) IN 0 alias oformu
select oformu
SCAN FOR ALLTRIM(PLATFORM)=="WINDOWS"
if !empty(Methods)
lHavMetod=.t.
Strtofile(Methods,cNametod)
IF Getfopen(cNametod,@nfop)
Racontext(NFOP)
endif
endif
ENDSCAN
SELECT oformu
use
NEXT
bi=ALEN(gafiles,2)
FOR i=1 TO ALEN(gafiles,1)
nSto=nSto+1
DIMENSION gastore(nSto,bi)
FOR j=1 TO ALEN(gafiles,2)
gastore[nsto,j]=gafiles[i,j]
NEXT
NEXT
ENDIF
oMens.Release
cStringTot="Total de Líneas"
IF LEN(cStringTot)>nMax
nMax=LEN(cStringTot)
ENDIF
nMaxLin=0
FOR i=1 TO ALEN(gastore,1)
IF gastore[i,2]>nMaxLin
nMaxLin=gastore[i,2]
ENDIF
NEXT
DO case
CASE nMaxLin>900000
cTRansf="99,999,999"
OTHERWISE
cTransf="9,999,999"
ENDCASE
FCR=ADDBS(xcDTEMP)+"Reportprg.txt"
nfop=FCREATE(fcr)
FOR i=1 TO 2
=FPUTS(nfop,PADR(gaClave[i,1]+"=",nMax+1)+transform(gaclave[i,3],ctransf))
NEXT
=fputs(nfop,"Total de Líneas por Prg")
lnLineas=0
STORE 0 TO lnLineas, lnBlank,lnComment
=FPUTS(nfop,PADR("Archivo",nMax)+" ";
+PADC("Código",LEN(cTransf))+" ";
+PADC("Blank",LEN(cTRansf))+" ";
+PADC("Comment",LEN(ctransf)))
FOR i=1 TO ALEN(gaStore,1)
lnLineas=lnLineas+gaStore[i,2]
lnBlank=lnBlank + gaStore[i,3]
lnComment=lnComment+gaStore[i,4]
=FPUTS(nfop,PADR(gaStore[i,1]+"=",nMax+1)+transform(gaStore[i,2],cTransf);
+" "+TRANSFORM(gaStore[i,3],cTRansf);
+" "+TRANSFORM(gaStore[i,4],cTRansf))
NEXT
=FPUTS(nfop,PADR(cSTringTot,nMax+1)+TRANSFORM(lnLIneas,cTransf);
+" "+TRANSFORM(lnBlank,cTransf);
+" "+TRANSFORM(lnComment,cTransf))
=FCLOSE(nfop)
RELEASE omens,gaclave
IF FILE(fcr)
o = CREATEOBJECT("Shell.Application")
o.ShellExecute("write.exe", '&fcr', "", "open", 1)
*MODIFY FILE &fcr noedit
ENDIF
*************************
PROCEDURE Racontext(NFOP)
*************************
DO WHILE !FEOF(nfop)
cString=UPPER(ALLTRIM(FGETS(nfop,2048)))
lProfun=.f.
DO case
CASE EMPTY(cString)
gafiles[si,3]=gafiles[si,3]+1
CASE LEFT(cString,1)="*"
gafiles[si,4]=gafiles[si,4]+1
CASE LEFT(cSTring,2)=REPLICATE("&",2)
gafiles[si,4]=gafiles[si,4]+1
OTHERWISE
FOR ri=1 TO ALEN(gaclave,1)
IF LEFT(cString,LEN(gaclave[ri,1]))==gaclave[ri,1]
IF gaclave[ri,2]
gaclave[ri,3]=gaclave[ri,3]+1
* gaclave[ri,4]=SUBSTR(cstring,LEN(gaclave[ri,1]))
lProfun=.t.
exit
endif
ENDIF
NEXT
IF !lProfun
gafiles[si,2]=gafiles[si,2]+1
endif
ENDCASE
ENDDO
=FCLOSE(NFOP)
ENDPROC
****************************************************
Procedure GetFopen(xcFile,npfop,xlNotVerb,nPrivileg)
********************************
*lGet=GetFopen(addbs(dtemp)+"archivo.txt",@nfop,lNotVerb)
*************************************************************
local cArchivo,lRet
if vartype(nPrivileg)#"N"
nPrivileg=0
endif
cArchivo=xcFile
lREt=.t.
IF !file(cArchivo)
if !xlNotVerb
GEtINforma("<NFOC/>El archivo &cArchivo no existe")
endif
lREt=.f.
endif
if lRet
npfop=fopen(cARchivo,nPrivileg)
if npfop=-1
if !xlNotVerb
GEtINforma("<NFOC/>El archivo &cArchivo no pudo abrirse")
endif
lREt=.f.
endif
endif
if lRet
gnEnd=Fseek(npfop,0,2)
gntop=Fseek(npfop,0)
if gnEnd<=0
if !xlnotVerb
GEtINforma("<NFOC/>El archivo &cArchivo no tiene contenido")
endif
fclose(npfop)
lRet=.f.
endif
endif
return lret
ENDPROC