Download MetaTrader 5
To add comments, please log in or register
Are you used to trading from your smartphone? Mobile version of MetaTrader 5 will suit you best!
Tradeing Trader
556
Tradeing Trader 2014.02.23 09:48 

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?

Simon Gniadkowski
Moderator
17963
Simon Gniadkowski 2014.02.23 09:50  
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 . . .
. ... Rick D. ... .
1077
. ... Rick D. ... . 2014.02.23 10:03  
Add new variable TakeProfit2, copy value of TakeProfit input to TakeProfit2, then modify and use TakeProfit2 in the code.
Alain Verleyen
Moderator
28633
Alain Verleyen 2014.02.23 10:16  
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.

Tradeing Trader
556
Tradeing Trader 2014.02.23 13:18  
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
whroeder1
13627
whroeder1 2014.02.23 16:57  
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
/
To add comments, please log in or register