Hello, my question - Pointers to the Functions.

 

Hello,

have anyone knows, how to call the function, that addres (entry point)

is taken from the table (for example Result=(Integer)Function(Data);)

where Integer is the entry point to the function taken from table.


It can be done by passing parameter to the IF sction,

but it's not good solution, for example:


If(CallID==0) {Result0=Function0(Data0);}

If(CallID==1) {Result1=Function1(Data1);}

If(CallID==2) {Result2=Function2(Data2);}

If(CallID==3) {Result3=Function3(Data3);}

...

Where CallID is an Integer taken from string StringToInteger(),

where string have been get as result of previous funcion.


I will be glad for answer,

thanks, PawelMQL5.

 
Maybe you would want to use an array of function pointers.
 
Dominik Christian Egert #:
Maybe you would want to use an array of function pointers.


It's not a Point, understood as the size of minimal price change - Point() function,

but Pointer like table Index Tab[i] but without table.

Entry Point is the address of RAM memory where the function code starts.

It can be relative.


But thanks for interest.

 
PawelMT5 #:


It's not a Point, understood as the size of minimal price change - Point() function,

but Pointer like table Index Tab[i] but without table.

Entry Point is the address of RAM memory where the function code starts.

It can be relative.


But thanks for interest.

See this example about array of function pointers

Array of Function Pointers compilation error in MQL5
Array of Function Pointers compilation error in MQL5
  • 2021.11.22
  • www.mql5.com
The below script compiles and works fine in MQL4 but throws compilation error(some operator expected) in MQL5...
 
Navdeep Singh #:

See this example about array of function pointers


Ok, thanks.  Its problably the solution.

I don't know, how to youe your pointers like " *  " in your MQL5.

Im from assembly language, there is no any problems with pointers to everything.


MOV EAX, [EBX]

MOV EAX, [RamAddress]


CALL [EAX]

CALL [RamAddress]


Thanks.

 

I'm sorry, but I dont understand, what program listed below is to do:

https://www.mql5.com/en/forum/382552


There is defined static table of I dont know what.

And there is the loop, that prints probably

Reapeated four times "Print(funcPtr[i](text))"


that funcPtr[i] is an static table filled with A,B,C,D

and (text) is probably do nothing, so this prints A,B,C,D in the next lines,

that is my theory.  I afraid to run this program on my PC.  I'll think about.

Array of Function Pointers compilation error in MQL5
Array of Function Pointers compilation error in MQL5
  • 2021.11.22
  • www.mql5.com
The below script compiles and works fine in MQL4 but throws compilation error(some operator expected) in MQL5...
 
Thank you for clearing out the difference between a Point() and a pointer to a function.

Again, an array of pointers to functions can be applied to your puzzle.

See the code MQLplus Error handling in code base, it uses exactly that to resolve custom error resolving functions in a dynamic way.

PS: MQL has no real addresses, they are a type of handle, and, if you are using an array, there is a bug which does not allow you to call a function pointer from an array. You need a single variable to store the pointer from the array and then call the function using this variable. (If the error still exists, which I believe)

Greetings and have fun solving your issue.
 

And so what.  Inside this program there is no comma between:

Print(funcPtr[i]   ,   (text));

comma please.


And I run this program, and its printed ASCII codes:

10   - one and zero 1 and zero

21   - two and one 2 and one  

32   - thre and two 3 and two

43  - four and thre 3 and thre


Are You kidding me?

It's just like:


for(i=0; i<4; i++) Print(string(i+1)+string(i));


Are you kidding?

Where is the pointer to the processor code?

Do you know what is processor code?

Please change Indicator file extension from ex5 to txt and open in the notepad.

A have ask of pointer to the CALL EAX, that CPU instruction calling your Function().

The Ask is - haw can I get an EAX content?


Look this:

lŠRőŚ ‘ˇXR‹;„oŃÖýçűŔáĚţQpÉC§Ü ÖËşŐŞNú*voSÄĆĎŃ9čňŰI“žT c§ľ4C%jiŘž„î@š1ÂȢů'V>áb 9Ć$j»bäcúŕFj

ájČ’šbrć‰a[sŃ|Ĺ f$ĐŻ|ž÷ˇAß%ń$7jť9é+U•˛íń´Ř”pFÂńNHp¸ĐÝęBŚŮ쎆1;÷·& ŰąęL2Î9ŰťŻ€# Vľˆ$Cˇčř6Â7Ô

{őVţWĺ6›<WóÜ«˝¨Ű] kíI Űţ¨GŔ #Iůü)ƒQ$ߣͼvż#— (ćö 'dü|Ý`ęýůęT"ĽÚƒwŮöĐŞKyܐz /·úr±)èý.jÂďŮ_q¶VůKľ

ËD˜ wë4­Ş,ĆI…[,Yq÷ óü'Uë$#_Čć#Nóv}ţX‰5DAÖ}ŮFłĺoĐ)eUMű+ĽşK"Ľ§ß­Ť}«kř!§,2ŐÁ(-СŻ    `¦-Ě·¬W˝*ç(5ë#


This is processor (CPU) code.

Im looking for an phisical, relative adress of entry to Function().  EIP - Extended Instruction Pointer content.

 
This is not CPU code, it is encrypted data, containing also the binary code.

Maybe you should think about how you are approaching not only your problem, but also the people here in the forum.

Your first reply to me was already making me think if I should answer "Hahahaha".

But I tri d to stay friendly. Don't expect more help from me, since you are so smart, you have been given all you need to know to solve your "silly" approach...


 
Dominik Christian Egert #:
This is not CPU code, it is encrypted data, containing also the binary code.

Maybe you should think about how you are approaching not only your problem, but also the people here in the forum.

Your first reply to me was already making me think if I should answer "Hahahaha".

But I tri d to stay friendly. Don't expect more help from me, since you are so smart, you have been given all you need to know to solve your "silly" approach...



What?  Encrypted?  Encrypted / Decrypted.  Military DES?  Decription/Encriotion standard.

Its not a cryptography.

Please for answer person who knows assembler, but not only desktop languages.

With asm knowledge please.

 
Yes, it is. Maybe you should get yourself familiar with MQL before you try to code.
MQL is a C/C++ like language. The compiler produces an encrypted binary container which will have all your code inside.
That's how it works.

Edit:
What the hell is a "desktop language"?
Reason: