We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpSyntax Questions › Reading an array of entries from a text file
Page Index Toggle Pages: 1
Reading an array of entries from a text file (Read 720 times)
Reading an array of entries from a text file
May 5th, 2010, 8:51am
 
I have a file which contains a number of entries about pictures, namely the file path, an effect to be applied and the time to display. Each piece of information is separated using a delimiter.

How can I load this separate information from the file? I can load say just the image path ok using
String textfile = selectInput(); pathname = loadStrings(file);

So, I'd ideally want to load the image path into pathname, the effect and then the time (the effect would be applied to that picture)

Any help appreciated! Smiley
Re: Reading an array of entries from a text file
Reply #1 - May 5th, 2010, 9:37am
 
loadStrings(), as the name implies, returns several strings in an array.
One string per line of your file.
Then you have to use split() on each line to get each field in a separate string.
Re: Reading an array of entries from a text file
Reply #2 - May 6th, 2010, 9:53am
 
Awesome. Thanks! Smiley
Page Index Toggle Pages: 1