Hi,
this is a short version of function and I forgot the following functions.
********************************************
FUNCTION TxtFileToArray(cDatei)
LOCAL i, x, hDatei
LOCAL aRest := {}
IF File(cDatei)
i := 0
hDatei := FOpen(cDatei)
IF hDatei > 0
DO WHILE !FEof(hDatei)
i ++
x := FReadLine(hDatei)
IF AllTrim(x) == Chr(26)
EXIT
ENDIF
IF Right(x,1) == Chr(26)
x := Left(x,Len(x)-1)
ENDIF
AAdd(aRest,Iif(lLtrim,Formkey(x,nCLen),x))
ENDDO
FClose(hDatei)
ENDIF
ENDIF
RETURN aRest
*****************
FUNCTION FReadLine(nHandle,cEol)
LOCAL cLine
DEFAULT cEol TO Chr(10)
HB_FreadLine(nHandle,@cLine,cEol)
IF Right(cLine,1) == Chr(13)
RETURN Left(cLine,Len(cLine)-1)
ENDIF
RETURN cLine
****************************************
**********************************************************************
/* Usage: fbof(handle) -> lStatus feof(handle) -> lStatus
Params: int handle - A handle returned from a previous call to
fopen() or fcreate().
Returns:
TRUE if the file pointer is at the beginning (fbof) or at
the end (feof) of the file associated with <handle>, FALSE if not
*/
FUNCTION FEof(nHandle)
************************
LOCAL nPos := FSeek(nHandle,0,1)
LOCAL nBot := FSeek(nHandle,0,2)
LOCAL lOk := (nPos >= nBot)
FSeek(nHandle,nPos,0)
RETURN lOk
*************************************************************************
FUNCTION fBof(nHandle)
**********************
LOCAL nPos := FSeek(nHandle,0,1)
LOCAL lOk := (nPos == 0)
RETURN lOk
******************************************************************************************
But you can also use Memoread() Function:
***********************************************************************
FUNCTION TxtFile2ArrayM(cDatei,nMaxLineLen)
LOCAL cText, nLines, i
LOCAL aRest := {}
DEFAULT nMaxLineLen TO 250
IF File(cDatei)
cText := MemoRead(cDatei)
nLines := MlCount(cText,nMaxLineLen)
ASize(aRest,nLines)
FOR i := 1 TO nLines
aRest[i] := Memoline(cText,nMaxLineLen,i)
NEXT
ENDIF
RETURN aRest