Funciones de Ficheros
Posted: Wed May 07, 2008 5:20 pm
Buenas tardes Foro, tengo una duda, tengo este código:
El mensaje de los numeros de lineas me sale a 0 (funcion flinecount) y tiene muchas lineas, os lo aseguro, ¿existe otra funcion para leer el nº de lineas de un fichero que no sea flinecount, o donde puede ver su uso?
P.D. la funcion freadline la he copiado de este foro, ¿Sabeis la constante FS_RELATIVE en que fichero de encabezados está?
Code: Select all
#include "fivewin.ch"
function main()
local nhandel,nume_line:=0,leido:="",i
nhandel:=fopen("fcli.txt")
nume_line = flinecount(nhandel)
msginfo(nume_line,"Nº de lineas")
for i = 1 to nume_line
freadline(nHandel,@leido)
msginfo(leido)
next i
return
function freadline( nHandle, nLineLen )
local cBuffer, nBytes, nAt
DEFAULT nLineLen := 512
cBuffer := Space( nLineLen )
nBytes = FRead( nHandle, @cBuffer, nLineLen )
nAt = At( Chr( 13 ) + Chr( 10 ), cBuffer )
if nAt != 0
FSeek( nHandle, -( nBytes - nAt + 2 ), FS_RELATIVE )
endif
return If(nAt !=0, SubStr( cBuffer, 1, nAt - 1 ), SubStr( cBuffer, 1, Bytes))
P.D. la funcion freadline la he copiado de este foro, ¿Sabeis la constante FS_RELATIVE en que fichero de encabezados está?