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

This seems to work;


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);

        // You could probably deal with line-endings more efficiently...
        match("%d %s", #line, note, str) &&
        note >= 0 && note < 128 ? (
          map[note] = str;
          str += 1;
        
      );
      file_avail(handle) ;
    );
  );
  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]);

Differences:
  • remove new line character from patterns
  • while loop condition is not file_avail
Do you see anything wrong with this method ?
X-Raym is offline   Reply With Quote