xHarbour Reference Documentation > Function Reference xHarbour Developers Network  

FParseLine()

Parses one line of a delimited text and loads it into an array.

Syntax

FParseLine( <cTextLine>, [<cDelimiter>]  ) --> aTextFields

Arguments

<cTextLine>
This is a character string holding on line of delimited text.
<cDelimiter>
This is a single character used to parse <cTextLine>. It defaults to the comma.

Return

The function returns a one dimensional array, or an empty array when an error occurs.

Description

Function FParseLine() parses one line of delimited text at <cDelimiter>. The result is stored in a one dimensional array.

FParseLine() is mainly designed to process the comma-separated values (or CSV) file format, were fields are separated with commas and records with new-line character(s).

Note:  function FParse() is available to process an entire CSV file.

Info

See also:FParse(), HB_FReadLine(), MemoLine()
Category: File functions , xHarbour extensions
Source:rtl\fparse.c
LIB:xhb.lib
DLL:xhbdll.dll

Example

// The example parses one line of delimited text and displays
// the resukt. Note that commas exist in the first and sixth
// text field of the CSV formatted string.

   PROCEDURE Main()
      LOCAL cText, aData

      cText := '"Jones, Mr",Male,"Oklahoma","IL",20041231,"Director, President"'

      aData := FParseLine( cText )

      FOR EACH cText IN aData
         ? LTrim( Str( HB_EnumIndex() ) ), cText
      NEXT

      ** Output
      // 1 Jones, Mr
      // 2 Male
      // 3 Oklahoma
      // 4 IL
      // 5 20041231
      // 6 Director, President
   RETURN

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