xHarbour Reference Documentation > Function Reference xHarbour Developers Network  

HB_FReadAndSkip()

Reads the current line and moves the record pointer.

Syntax

HB_FReadAndSkip() --> cLine

Return

The function returns the current line in the currently selected text file as a character string.

Description

HB_FReadAndSkip() reads the current line in the currently selected text file and advances the record pointer to the next line. The function is especially designed for reading CSV files that may contain quoted Carriage return, Line feed characters (CRLF). CRLF characters are not recognized as end-of-line markers when they are part of a quoted character string.

Info

See also:FOpen(), FSeek(), HB_FReadLine(), HB_FReadLN(), HB_FSelect(), HB_FUse()
Category: File functions , Text file functions , xHarbour extensions
Source:misc\hb_f.c
LIB:libmisc.lib

Example

// The example fills an array with the lines of a text file,
// taking advantage of implicit record pointer movement of
// function HB_FReadAndSkip().

   PROCEDURE Main
      LOCAL cFile := "Textfile.txt"
      LOCAL aLines, nLine := 0, nCount
      LOCAL nFile

      nFile  := HB_FUse( cFile )
      nCount := HB_FLastRec() + 1
      aLines := Array( nCount )

      DO WHILE ++nLine <= nCount
         aLines[ nLine ] := HB_FReadAndSkip()
      ENDDO

      HB_FUse()

      AEval( aLines, {|cLine| QOut( cLine ) } )
   RETURN

Copyright © 2006-2007 xHarbour.com Inc. All rights reserved.
http://www.xHarbour.com
Created by docmaker.exe