Change the retrieved value on the snippet

I want to get the test value (Cre in the example) from the electronic medical record (chart), if any, and auto-populate the form text. However, I cannot change the value of form text afterwards. How can I make it possible to change the retrieved value on the snippet?

{chart="Cre 1.3 MG/DL"}{if: {=testregex({=chart}, "Cre.*MG/DL") }}{cre_all=extractregex({=chart},"Cre.*MG/DL")}{cre=extractregex({=cre_all},"\d+(?:.\d+)?"); trim=yes}{endif}
{formtext: name=cre}

cre variable matches name of the formtext and it constantly gets set to same value. Therefore changing formtext input resets it back to the value assigned to the variable.

run command seems like a perfect fit for this case. It runs only once and does not interfere after you start changing the input. Here is a small example:

{run: chart="Cre 1.3 MG/D"
if testregex({=chart}, "Cre.*MG/DL")
cre_all=extractregex({=chart},"Cre.*MG/DL")
cre=extractregex({=cre_all},"\d+(?:.\d+)?")
endif
}

{formtext: name=cre}

@Mansur_Kutybayev
Thank you for your prompt reply.

But it doesn't seem to work.

I am thinking of extracting 1.3 from Chart as the default value, but it can be changed later.

Am I mistaken?

chart variable had wrong value, here I fixed it. The default value for formtext is going to be 1.3 and later you would be able to change it.

{run: chart="Cre 1.3 MG/DL"
if testregex({=chart}, "Cre.*MG/DL")
cre_all=extractregex({=chart},"Cre.*MG/DL")
cre=extractregex({=cre_all},"\d+(?:.\d+)?")
endif
}

{formtext: name=cre}

@Mansur_Kutybayev
Thank you very much !!