- Alexander Hoch: Normaly, we have to define variables like ( index=i), like this:
DP_Button[i]. DP_SetupNumber=1;
DP_Button[i]. DP_SetupName = "Hallo World";
DP_Button[i]. DP_ButtonNumber=i;
Just define an initiator.
Struct DP_ButtonRecord { void init(int sn, string n, int bn){ DP_SetupNumber=sn; DP_SetupName = n; DP_ButtonNumber=bn; } ⋮ }; // DP_ButtonRecord DP_Button[x].init(1, "Hallo World", i);
- Alexander Hoch: Is there any posibility to take access on the variables without always writing DP_Button[i], to define like this example?Define a default constructor
with (DP_Button[i]) do { DP_SetupNumber=1; DP_SetupName = "Hallo World"; DP_ButtonNumber=i; }
Struct DP_ButtonRecord { DP_ButtonRecord() : DP_SetupNumber(1), DP_SetupName("Hallo World"), DP_ButtonNumber(i){} //[cTor]
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Hi,
here's an example of my Question/Problem?
Lets define the following structure ...
struct DP_ButtonRecord { int DP_SetupNumber; string DP_SetupName; int DP_ButtonNumber; .....
The variable for the Structure is definied as a an array of 10 Elements.
DP_ButtonRecord DP_Button[10];
Normaly, we have to define variables like ( index=i), like this:
DP_Button[i]. DP_SetupNumber=1;
DP_Button[i]. DP_SetupName = "Hallo World";
DP_Button[i]. DP_ButtonNumber=i;
Is there any posibility to take access on the variables without always writing DP_Button[i], to define like this example?
with (DP_Button[i]) do { DP_SetupNumber=1; DP_SetupName = "Hallo World"; DP_ButtonNumber=i; }
If yes, please let me know how.
If NO, this feature would be very helpful for reducing Programcode and make it clearer.
Thanks al lot for all hints, you let me know about my Question.
Alex