Mike Serra wrote:Buenas tardes Foro, tengo una duda, tengo este código:
- Code: Select all Expand view RUN
#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))
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á?
Información de fLineCount()
FLineCount()
Counts the lines in an ASCII text file.
Syntax
FLineCount( <cFileName> ) --> nLineCount
Arguments
<cFileName>
This is a character string holding the name of the text file whose lines to count. It must include path and file extension. If the path is omitted from <cFileName>, the file is searched in the current directory. Return
The function returns the number of lines contained in <cFileName> as a numeric value. If the file <cFileName> does not exist or cannot be opened, the return value is zero.
Description
FLineCount() is an optimized function for counting the lines in an ASCII text file fast and efficiently. It can be used in conjunction with HB_FReadLine() to extract single lines from an ASCII text file.
Otra función parecida:
HB_FLastRec()
Returns the number of lines in the currently selected text file.
Syntax
HB_FLastRec() --> nLineCount
Return
The function returns the number of lines in the currently selected text file as a numeric value.