Errors, bugs, questions - page 1439
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
As my experience shows, if the programmer writes something into an array containing 10 items with index 20, it most likely means that he/she made a mistake and the program should generate an error instead of increasing the array's size, thereby hiding a questionable action.
All those "arrays adjusting the size" are much more troublesome in terms of hiding potential errors than convenience. What's more, not having to keep track of an array's size is also a potentially dangerous practice, leading to hard-to-fix bugs.
Is it me, or haven't you worked with the languages in question? You don't have to specify an index to be added at all: it is assigned automatically and the array's size is also increased. The programmer just doesn't have a chance to make a mistake with the index during this operation.
You can implement similar behavior with classes, add the related functions pop, shift, unshift, etc. And drag a wagon of classes from code to code, with each code using %10...20 functions from it. Does this sound like a good solution? An example of right solution in my opinion is adding to ObjectsDeleteAll function the ability to delete by prefix - this is another micron towards higher level programming - and most coders flew into recycle bin so self-made function. Alas, we'll hardly see that with arrays...
И таскать телегу классов из кода в код, при том что в каждом коде из неё используются %10..20 функций.
No need to write "smart array" classes, they are already in the MetaQuotes Standard Library, see the Arry class family
Is it just me, or haven't you worked with the languages in question? You don't have to specify an index to the added element at all, it is assigned automatically and the array's size is also increased. The programmer just doesn't have a chance to make a mistake with the index during this operation
Uhhhh... What chances the programmer has to make a mistake? You are wrong to think that you can take into account all variants of any complex program.
All those "default actions" must be properties of complex objects. Simple objects, such as variables, arrays and simple structures - must have as few "default" properties as possible.
For example, on creation - they must store an undefined value, not zero.
You can implement similar behavior with classes, add related functions pop, shift, unshift etc. And drag a wagon of classes from code to code, with each code using %10...20 functions from it. Does this sound like the right solution?
It's the right solution in terms of logic. When working with such classes - their behavior is transparent.
And what about "dragging a cartload of classes" - when coding you don't drag them, you just plug in the library. And when compiling, a normal linker shouldn't put into an executable all methods from the library, but only those that are used.
Example of right solution in my opinion - adding to ObjectsDeleteAll function delete by prefix - this is another micron towards higher level programming - and most coders have got flew into trash this self-made function. Alas, this is unlikely to happen with arrays...
In my opinion, this is also a wrong approach, for the same reason. The function is loaded with tasks that are not typical of it and do not follow the logic of its application.
The correct solution, it seems to me, is to have a class object manager on the graph that keeps a list of them, and removes the necessary ones as functions are called. The name prefixes, it seems to me, should serve solely to make some information on the object clear to a person. And deletion - should not be based in any way on the name of the object, but on saving that name in an array.
version 5.0 build 1150, demo
Update your terminal (you need to connect to the MetaQuotes-Demo server). Current build:
This is the script:
Gives this result:
Update your terminal (you need to connect to the MetaQuotes-Demo server). Current build:
This is the script:
Gives this result:
Thanks, do you know why the flag has a value of 0, as if nothing has changed