View Single Post
Old 06-26-2019, 04:08 AM   #20
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 6,799
Default

@Tale
Thx for your help !


Unfortunatly this face the same problem has I had when testing: either only the first or last line works.


Here is a full exemple:


CSV:


Code:
37 banjo.png
36 cowbell.png

JSFX:
Code:
desc:Parse MIDI Note Name File

slider2:36<0,127,1>Base Note

slider30:/track_icons:none:Text File 

////////////////////////////////////////////////////////////////////////////////
@init

////////////////////////////////////////////////////////////////////////////////
@slider
undef = 0;
strcpy(undef, "[Undef]");
memset(map, undef, 128);

handle = file_open(slider30);
handle >= 0 ? (
  file_text(handle) ? (
    str = undef + 1;
    while(
      file_string(handle, #line);
      file_avail(handle) ? (
        // You could probably deal with line-endings more efficiently...
        (match("%d %s\r\n", #line, note, str) ||
        match("%d %s\n", #line, note, str)) &&
        note >= 0 && note < 128 ? (
          map[note] = str;
          str += 1;
        );
        1; // while
      );
    );
  );
  file_close(handle);
);

@gfx 100 32

gfx_setfont(1, "Arial", 20);
gfx_r=1; gfx_b=1; gfx_g=1; gfx_a=1;
gfx_x=gfx_y=5;

gfx_drawstr(map[slider2]);

In this case, 37 do return "banjo.Png" as expected, but 36 return "[Undef]"...



Any idea ?
X-Raym is offline   Reply With Quote