constant cannot be modified

 

Hello,

when ii try to change the value of a setting "input Takeprofit" then i get the compiler error message "constant cannot be modified" but why? It was always possible in the mql4 language to change the value of such a extern setting parameter.

Is there a solution? I am thinking to write again the old style "extern Takeprofit" then it does work. But why with "input" it does not work or does i make somethink wrong?

 
PlanandTrade:

Hello,

when ii try to change the value of a setting "input Takeprofit" then i get the compiler error message "constant cannot be modified" but why? It was always possible in the mql4 language to change the value of such a extern setting parameter.

Is there a solution? I am thinking to write again the old style "extern Takeprofit" then it does work. But why with "input" it does not work or does i make somethink wrong?

input takeprofit is not valid . . . neither is extern takeprofit . . .
 
Add new variable TakeProfit2, copy value of TakeProfit input to TakeProfit2, then modify and use TakeProfit2 in the code.
 
PlanandTrade:

Hello,

when ii try to change the value of a setting "input Takeprofit" then i get the compiler error message "constant cannot be modified" but why? It was always possible in the mql4 language to change the value of such a extern setting parameter.

Is there a solution? I am thinking to write again the old style "extern Takeprofit" then it does work. But why with "input" it does not work or does i make somethink wrong?

Because "input" parameters are read only. If you want to use a new feature, I strongly suggest you to read the documentation.

The input storage class defines the external variable. The input modifier is indicated before the data type. A variable with the input modifier can't be changed inside mql4-programs, such variables can be accessed for reading only. Values of input variables can be changed only by a user from the program properties window.

 
RickD:
Add new variable TakeProfit2, copy value of TakeProfit input to TakeProfit2, then modify and use TakeProfit2 in the code.

that was also a way i was thinking, but i did wonder why it was not more possible to change the variable when i use the "input" declaration
 
The documentation is clearhttps://docs.mql4.com/en/basis/variables/inputvariablesA variable with the input modifier can't be changed inside mql4-programs, such variables can be accessed for reading only. Values of input variables can be changed only by a user from the program properties window
Reason: