Error while write value into a register

Hi,

I am trying to write values into one of a register in a register array. But I got this error while compiling:

“error: write_S3_no_vote_array.execute: Conditional execution in actions unsupported on this target”

here is my code in ingress:

count_value_t countWriteVal;
Register<count_value_t, register_array_size_t>(register_array_size, 0) S3_no_vote_array;
RegisterAction<count_value, register_array_size_t, count_value_t>(S3_no_vote_array) write_S3_no_vote_array = {
void apply(inout count_value_t val, out count_value_t rv) {
val = countWriteVal;
}

// and in an action:
action s3() {
if (ig_md.flag == true) {
countWriteVal = 100;
write_S3_no_vote_array.execute(ig_md.arrayIndex);
}
}

=====================
are there anything I wrote wrong?

Oh I know!
I cannot use if in an action😭

Correct! :slight_smile:

But you can use metadata as a key in a table. That could solve your problem :wink:

Cheers,

1 Like

yeah, it’s a great help!!! thanks!!!

hey,
can I put those ifs into an apply{} ? cause I need to change values in ig_md.
And can ‘write_S3_no_vote_array.execute(ig_md.arrayIndex);’ work in an apply{} body?

Hi,

I believe both can be used in the apply block.

Cheers,