View Single Post
Old 09-19-2016, 04:39 PM   #1
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 6,799
Default Q: Parse CSV file with JSFX

Hi,

I am a bit confused that string format and function in JSFX.

imagine a file like
Code:
45-50
40-51
68-98
The seperator - can be replace with any other separator.


Here is the code for sampling a file (from MIDI Pattern/Scale Variation Generator [IXix])
Code:
@slider
seqFile != slider8 ?
(
  seqFile = slider8;
  seqSize = 0;
  fileHandle = file_open(slider8);
  fileHandle > 0 && file_text(fileHandle) ?
  (
    while
    (
      file_var(fileHandle,seq[seqSize]);
      file_avail(fileHandle) ? seqSize += 1;
    );
    file_close(fileHandle);
  );
);
You can then access a line with seq[x] where x is the number of the line.

But how will you return two variables from that line ? How would you parse the "45-50" into two int variable ?
I only succeed to get int when there is only one number per line, but not two with a sperator.

Thanks for your help !

Last edited by X-Raym; 09-19-2016 at 07:30 PM.
X-Raym is offline   Reply With Quote