Need a simple coding help - Get File Name + String to Integer....!

 

Hii guys it would be awesome if you can help me out here,


i need to get the EA file name and remove the strings from its name and have the final result in only numbers,

EXAMPLE:

EA name is "JOHNCORE 112.32231"

we need to get the name of the EA file from with-in the code somehow,

then from the file name "JOHNCORE 112.32231" we will need to remove the strings, which are "JOHNCORE" & ".",

in order to get our final result which would be only in numbers "11232231".


please can someone help me with that simple thing?, god bless if you can.

thanks i would be waiting for replies..

 
ArikKarish:

Hii guys it would be awesome if you can help me out here,


i need to get the EA file name and remove the strings from its name and have the final result in only numbers,

EXAMPLE:

EA name is "JOHNCORE 112.32231"

we need to get the name of the EA file from with-in the code somehow,

then from the file name "JOHNCORE 112.32231" we will need to remove the strings, which are "JOHNCORE" & ".",

in order to get our final result which would be only in numbers "11232231".


please can someone help me with that simple thing?, god bless if you can.

thanks i would be waiting for replies..

Use StringSplit() and Stringreplace() functions
 
Mladen Rakic:
Use StringSplit() and Stringreplace() functions

but how about getting the file name? could someone just please help me to build this function please ?

 
ArikKarish:

we need to get the name of the EA file from with-in the code somehow,

then from the file name "JOHNCORE 112.32231" we will need to remove the strings, which are "JOHNCORE" & ".", in order to get our final result which would be only in numbers "11232231".

  1. Perhaps you should read the manual. The first is easy: WindowExpertName - Chart Operations - MQL4 Reference
  2. The second doesn't require StringSplit at all.
    Not compiled
    string numerics_only(string text){
       int iPos=0; 
       while(iPos < StringLen(text)){
          string c = StringSubstr(text, iPos, 1);
          if(c < "0" || c > "9") StringReplace(text, c, "");
          else ++iPos;
       }
       return text;
    }
    Not compiled

    Was that so hard you couldn't even attempt it?

  3. The real question is why would you want to do something different if someone renames the file?
 

whroeder1:

...

2. The second doesn't require StringSplit at all.

...

Whatever :) :) :)
 

Thank you all guys for your time and help!, godbless,


i created the thing i wanted to create with the help of @whroeder1 thank you sir! you just saved me ton of manual work XD,

godbless and have a great week!

Reason: