byte-address-first

nazarijtipusak080/buffer1-byte-address/byte-address-first

Returns the address of the specified byte in the buffer (you can check part of the buffer by specifying a start-of-length limit in "first"). If the byte is repeated in the buffer, outputs the first of the addresses. If the specified byte is not in the buffer, outputs -1.
byte-address-first
@/byte-address-first
Returns the address of the specified byte in the buffer (you can check part of the buffer by specifying a start-of-length limit in "first"). If the byte is repeated in the buffer, outputs the first of the addresses. If the specified byte is not in the buffer, outputs -1.
buffer1nazarijtipusak080/buffer1/buffer1
valuebyte
lennumber
firstnumber
triggerpulse
byte-address-first
buffer1
value
len
first
trigger
i
done
ERR
ERRpulse
donepulse
inumber
To use the node in your project you should have the nazarijtipusak080/buffer1-byte-address library installed. Use the “File → Add Library” menu item in XOD IDE if you don’t have it yet. See Using libraries for more info.

C++ implementation

struct State {
    // не використовується
};

{{ GENERATED_CODE }}

void evaluate(Context ctx) {
    if (!isInputDirty<input_trigger>(ctx)) return;
 if (isInputDirty<input_trigger>(ctx)) emitValue<output_i>(ctx,(-1));
    // Отримуємо об'єкт буфера
    auto _object = getValue<input_buffer1>(ctx); // буфер
    uint16_t len = static_cast<uint16_t>(getValue<input_len>(ctx));
     uint16_t first = static_cast<uint16_t>(getValue<input_first>(ctx));
    char value = getValue<input_value>(ctx); // char
    // Перевірка, чи існує буфер і чи є правильна довжина
    if (!_object->buffer || len > _object->len) {
        emitValue<output_ERR>(ctx, 1);  // видаємо помилку
        return;
    }

    // Зсув байтів вліво
    for (int16_t i = first; i < len; i++) {
      if ( _object->buffer[i] == value){
         emitValue<output_i>(ctx, i)  ;
      break;}
    }
    
   
    // Виводимо успіх
    emitValue<output_done>(ctx, 1);
}