bool32.rising trigger
int32 index
bool32 first
bool32 last
bool32 rnd
bool32 autoload
charptr32 selected
charptr32 free
table prefix
table suffix
int32.label free
int32.label sel
int ntrig, stop;
int cnt = 0;
char c[64], C[64];
int offset;
int pval, first, I;
ntrig = 0;
strcpy(&c[0], "attr_prefix000attr_suffix");
offset = strlen("attr_prefix");
strcpy(&C[0], "attr_prefix000attr_suffix");
pval = 0;
cnt = 0;
stop = 0;
if (inlet_findFree && !ntrig) {
stop = 0;
ntrig = 1;
} else if ((!inlet_findFree) && ntrig) {
ntrig = 0;
}
while (!stop) {
int i = cnt;
int i0 = i / 10;
C[offset + 2] = '0' + i - 10 * i0;
i = i0;
i0 = i / 10;
C[offset + 1] = '0' + i - 10 * i0;
i = i0;
i0 = i / 10;
C[offset + 0] = '0' + i - 10 * i0;
FIL FileObject;
FRESULT err;
err = f_open(&FileObject, &C[0], FA_READ | FA_OPEN_EXISTING);
if (err == FR_OK) {
cnt += 1;
} else if (err != FR_OK) {
stop = 1;
}
}
outlet_autoload = 0;
if ((inlet_index) != pval) {
pval = inlet_index;
int i = inlet_index % (cnt > 0 ? cnt : 1);
I = i;
int i0 = i / 10;
c[offset + 2] = '0' + i - 10 * i0;
i = i0;
i0 = i / 10;
c[offset + 1] = '0' + i - 10 * i0;
i = i0;
i0 = i / 10;
c[offset + 0] = '0' + i - 10 * i0;
outlet_autoload = 1;
}
int trg = inlet_first || inlet_last || inlet_rnd;
if (trg && !first) {
first = 1;
int i = 0;
if (inlet_last) {
i = cnt - 1;
} else if (inlet_rnd) {
i = (int32_t)((GenerateRandomNumber() >> 6) % cnt);
}
I = i;
int i0 = i / 10;
c[offset + 2] = '0' + i - 10 * i0;
i = i0;
i0 = i / 10;
c[offset + 1] = '0' + i - 10 * i0;
i = i0;
i0 = i / 10;
c[offset + 0] = '0' + i - 10 * i0;
outlet_autoload = 1;
} else if (!trg) {
first = 0;
}
outlet_selected = &c[0];
outlet_free = &C[0];
disp_free = cnt;
disp_sel = I;