Any questions from a PROFI to a SUPER PROFI - 1. - page 3

 
Holy simplicity (c) Jan Hus
 
Sorento:
Holy simplicity (c) Jan Hus

What do you mean?
 
drknn:

What do you mean?

It's not that simple.

now inside the function - work with the passed variable.

As math teaches us - if you passed a pseudo-variable by address - all the wonders in it are gone.

But if the address pool is lined up with constants - everything will be different.

0 becomes 1 and vice versa.

;)

 
Why would you need such complications in an EA/indicator/script, such as passing a variable by address? What do you mean by the terms: pseudo-variable, address pool and constant alignment?
 
drknn:
Why do you need such complexities in an EA/indicator/script, like passing a variable by address? What do you mean by the terms: pseudo-variable, address pool and constant alignment?

compilers and interpreters are similar.

So think about it.

How are parameters (variables) passed to a function, and if an expression is passed to a function...

;)

 
Sorento:

I share my doubts as well.

I don't pretend to be a super-professional, I don't reach the level of a pro - nobody reads messages... it's clear to the horse's eye.

But the more I write code (not much so far) - a question occurs:

How are parameters passed in functions?

(by name or by value?)

I have a suspicion that string variables get jittery when passing them...

;)


Although I don't consider myself a pro or a super pro, but I'll try to answer :).

MT is implemented in C2C++ and the developers recommended to consult the standards of this language in case of any uncertainty.

According to the C2C++ standard, all parameters except arrays are passed by value, including expressions. That is, copies of parameters are passed: changing a parameter passed by value within a called function does not cause the parameter in the external calling function to be changed. If the change is required, it must be passed by reference (by address) - that is, the address at which the variable passed as a parameter is located is passed. Then the value located at this address can be changed, the address cannot be changed. All arrays are passed by reference, i.e., addresses are passed immediately: otherwise, a huge amount of data would have to be copied across the stack.

To prevent a parameter passed by reference from being changed within the function being called, C/C++ uses the const modifier.

In C2C++, strings are character arrays, with one difference: such an array must end with the string terminator '\0'.

In MCL, a string is a structure containing the size and pointer to the string (i.e. the string array itself), if the examples are to be believed.

This example is for C2C++ :

//----
struct MqlStr
  {
   int               len;
   char             *string;
  };

Here char * is a pointer to a variable of character type (char type). The pointer type itself (char*, int*, double*.......) is always an integer - it's a cell address. This means that the variable does not store a string, but a cell address. The value of the character itself can be retrieved like this : *string or string[0]. To work, we should always allocate memory for an array if it is not placed statically, i.e., its size is not specified in the description, e.g., like this

char string[1025] ;

is an array of characters, of 1025 elements.... If the last character (string[1024]='\0'), the array could be treated as a string of 1024 characters.

String elements can be received as elements of the usual array string[i]. When placing dynamically, a string is assigned + 1 element and the last character of the string's end is......

Accordingly, the string is always passed by reference. Whether it is forbidden to modify it depends on ICL implementation and it can be checked with example: pass a string to function, change value there and read it (this value) after called function terminates.

Good luck.

 
VladislavVG:

Accordingly, the string is always passed by reference. Whether they can be modified depends on the MCL implementation and can be checked with an example: pass a string to a function, change the value there and read it (this value) after the called function is finished.

Modification is not forbidden. Checked.
 
drknn:

Oh, bollocks. It must be a question for developers, or everything is not all right in the DLL. I'm not a C++ programmer - tried to make a couple of programs once, but I've encountered that while you have a C++ shell installed, everything works. But as soon as you transfer the executable to another computer, as soon as you discover the lack of some dll-cycle. I also don't like working with strings. I gave up that language and settled on Delphi. Maybe you can try to make your dll on it - such dlls are quite normal with the terminal...

P.S.

So, I don't understand why everyone praises C++ so much, if even at the level of choosing a shell for programming problems arise with this language...

The thing is, all the libraries and scripts with these libraries work fine if you load them manually on a chart. They also work if you load them onto the chart programmatically from the current process.

The problem occurs when you load them from a remote process.

=====================================

Regarding transferring the code to another computer. Most likely you were migrating a debugger version. It pulls the debugging libraries from Studio. You should have compiled the release. Then everything would have worked everywhere.

 
I was wrong to call it by analogy.
 
TheXpert:
I was wrong to call it by analogy.

Right. I even blinked at the terms of this thread's title - I hadn't noticed that the names were different - my attention was already tuned to a particular pattern.
Reason: