INPUTCSV

INPUTCSV #handle, var[, var2[, varn ] ]

Description:

Read a comma separated (or delimited) value or values from the file for #handle.  This is a new feature for Liberty BASIC v4.5.0.

This allows your program to read a line of text where the text has commas to separate the different values, like the regular INPUT #handle statement does but it also pays attention to quotation marks.  This makes it possible to read files that have commas between the quotation marks and those commas are part of the data.

For example if you have a data item which is last name, first name format it can be read using this command.  Here is an example with a name, a phone number, and a date:

  "Jones, Timothy", 444-6823, 04/01/1970

You can read this data with the following statement:

  INPUTCSV #handle, memberName$, phone$, birthday$

Usage:

The example below writes these two lines of text containing 4 comma separated items.  Notice the quotation marks.

  this,"is, a test, of"
  "the emergency",broadcast system

Then it reads those 4 items and prints them out one line each.

  open "somefile.txt" for output as #writeFile
  print #writeFile, "this,";chr$(34);"is, a test, of";chr$(34)
  print #writeFile, chr$(34);"the emergency";chr$(34);",broadcast system"
  close #writeFile

  open "someFile.txt" for input as #readFile
  inputcsv #readFile, a$, b$, c$, d$
  print a$
  print b$
  print c$
  print d$
  close #readFile
  end

 

See also: INPUT$(#h, n), INPUTTO$(#h, c$), Line Input, INPUT