# Error while write value into a register

**URL:** <https://forum.p4.org/t/error-while-write-value-into-a-register/334>\
**Category:** Getting Started with P4\
**Created:** [May 16, 2022, 7:12am UTC](https://forum.p4.org/t/error-while-write-value-into-a-register/334 "2022-05-16T07:12:21Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![AcmeT](https://avatars.discourse-cdn.com/v4/letter/a/f1d935/32.png) [@AcmeT](https://forum.p4.org/u/AcmeT)\
**Post date:** [May 16, 2022, 7:12am UTC](https://forum.p4.org/t/error-while-write-value-into-a-register/334/1 "2022-05-16T07:12:21Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![AcmeT](https://avatars.discourse-cdn.com/v4/letter/a/f1d935/32.png) [@AcmeT](https://forum.p4.org/u/AcmeT)\
**Post date:** [May 16, 2022, 7:26am UTC](https://forum.p4.org/t/error-while-write-value-into-a-register/334/2 "2022-05-16T07:26:00Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![ederollora](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.p4.org/ederollora/32/21_2.png) [@ederollora](https://forum.p4.org/u/ederollora)\
**Post date:** [May 16, 2022, 8:47am UTC](https://forum.p4.org/t/error-while-write-value-into-a-register/334/3 "2022-05-16T08:47:58Z")

</div>

Correct! 🙂

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

Cheers,

---

<div class="post-metadata">

**Author:** ![AcmeT](https://avatars.discourse-cdn.com/v4/letter/a/f1d935/32.png) [@AcmeT](https://forum.p4.org/u/AcmeT)\
**Post date:** [May 16, 2022, 4:26pm UTC](https://forum.p4.org/t/error-while-write-value-into-a-register/334/4 "2022-05-16T16:26:03Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![AcmeT](https://avatars.discourse-cdn.com/v4/letter/a/f1d935/32.png) [@AcmeT](https://forum.p4.org/u/AcmeT)\
**Post date:** [May 17, 2022, 3:30am UTC](https://forum.p4.org/t/error-while-write-value-into-a-register/334/5 "2022-05-17T03:30:01Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![ederollora](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.p4.org/ederollora/32/21_2.png) [@ederollora](https://forum.p4.org/u/ederollora)\
**Post date:** [May 17, 2022, 7:49am UTC](https://forum.p4.org/t/error-while-write-value-into-a-register/334/6 "2022-05-17T07:49:41Z")

</div>

Hi,

I believe both can be used in the `apply` block.

Cheers,

---

<div class="post-metadata">

**Author:** ![vgurevich](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.p4.org/vgurevich/32/23_2.png) [@vgurevich](https://forum.p4.org/u/vgurevich)\
**Post date:** [May 22, 2022, 7:03pm UTC](https://forum.p4.org/t/error-while-write-value-into-a-register/334/7 "2022-05-22T19:03:57Z")

</div>


