substring issues

21 views
Skip to first unread message

Jos

unread,
May 12, 2012, 10:44:18 AM5/12/12
to MqlLock
Hi,

the following code will produce issues when mql-locked.

Every last character of strings inserted, will turn into %00 instead
of the actual character it should be (or was).

string URLEncode(string toCode)
{
int max = StringLen(toCode);
string RetStr = "";
for(int i=0;i<max;i++) {
string c = StringSubstr(toCode,i,1);
int asc = StringGetChar(c, 0);
Print("String: ",toCode, "i: ",i, "Str: ",c," Asc: ",asc);
if((asc > 47 && asc < 58) || (asc > 64 && asc < 91) || (asc > 96
&& asc < 123))
RetStr = StringConcatenate(RetStr,c);
else if (asc == 32)
RetStr = StringConcatenate(RetStr,"+");
else {
if(hex(asc) != "00") {
RetStr = StringConcatenate(RetStr,"%",hex(asc));
}else{
RetStr = StringConcatenate(RetStr,c);
}
}
}
return (RetStr);
}

Fx1 Inc

unread,
May 15, 2012, 2:36:33 AM5/15/12
to mql...@googlegroups.com
Hi Jos,

do you mind to post us the hex() function as .mqh or .dll please? So we can test this case?
--
HIGH RISK DISCLOSURE: Foreign exchange trading carries a high level of risk that may not be suitable for all investors. Leverage creates additional risk and loss exposure. Before you decide to trade foreign exchange, carefully consider your investment objectives, experience level, and risk tolerance. You could lose some or all of your initial investment; do not invest money that you cannot afford to lose. Educate yourself on the risks associated with foreign exchange trading, and seek advice from an independent financial or tax advisor if you have any questions. ADVISORY WARNING:Fx1.net provide references and links to selected blogs and other sources of economic and market information as an educational service to our users and we do not endorse the opinions or recommendations of the blogs or other sources of information. Users are advised to carefully consider the opinions and analysis offered in the blogs or other information sources in the context of the user's individual analysis and decision making. None of the blogs or other sources of information is to be considered as constituting a track record. Past performance is no guarantee of future results and we specifically advise users to carefully review all claims and representations made by advisors, bloggers, money managers and system vendors before investing any funds or opening an account with any Forex dealer. Any news, opinions, research, data, or other information contained within this website is provided as general market commentary and does not constitute investment or trading advice. We expressly disclaim any liability for any lost principal or profits without limitation which may arise directly or indirectly from the use of or reliance on such information. As with all such advisory services, past results are never a guarantee of future results. US CFTC RULE 4.41 - HYPOTHETICAL OR SIMULATED PERFORMANCE RESULTS HAVE CERTAIN LIMITATIONS. UNLIKE AN ACTUAL PERFORMANCE RECORD, SIMULATED RESULTS DO NOT REPRESENT ACTUAL TRADING. ALSO, SINCE THE TRADES HAVE NOT BEEN EXECUTED, THE RESULTS MAY HAVE UNDER-OR-OVER COMPENSATED FOR THE IMPACT, IF ANY, OF CERTAIN MARKET FACTORS, SUCH AS LACK OF LIQUIDITY. SIMULATED TRADING PROGRAMS IN GENERAL ARE ALSO SUBJECT TO THE FACT THAT THEY ARE DESIGNED WITH THE BENEFIT OF HINDSIGHT. NO REPRESENTATION IS BEING MADE THAT ANY ACCOUNT WILL OR IS LIKELY TO ACHIEVE PROFIT OR LOSSES SIMILAR TO THOSE SHOWN.

Jos

unread,
May 21, 2012, 12:35:49 PM5/21/12
to MqlLock
I tested this with control variables, and the issue is actually in the
way it changes StringSubStr, not the hex thing.

But here it is anyway:

string hex(int i)
{
static string h = "0123456789ABCDEF";
string ret="";
int a = i % 16;
int b = (i-a)/16;
if (b>15) ret = StringConcatenate(hex(b), StringSubstr(h,a,1));
else ret = StringConcatenate(StringSubstr(h, b ,1),
StringSubstr(h,a,1));

return (ret);
}

On May 15, 8:36 am, Fx1 Inc <i...@fx1.net> wrote:
> Hi Jos,
>
> do you mind to post us the hex() function as .mqh or .dll please? So we
> can test this case?
>
>
>
>
>
> > Hi,
>
> > the following code will produce issues when mql-locked.
>
> > Every last character of strings inserted, will turn into %00 instead
> > of the actual character it should be (or was).
>
> > string URLEncode(string toCode)
> > {
> >    int max = StringLen(toCode);
> >    string RetStr = "";
> >    for(int i=0;i<max;i++) {
> >      string c = StringSubstr(toCode,i,1);
> >      int  asc = StringGetChar(c, 0);
> >      Print("String: ",toCode, "i: ",i, "Str: ",c," Asc: ",asc);
> >      if((asc>  47&&  asc<  58) || (asc>  64&&  asc<  91) || (asc>  96
> > &&  asc<  123))
> >        RetStr = StringConcatenate(RetStr,c);
> >      else if (asc == 32)
> >        RetStr = StringConcatenate(RetStr,"+");
> >      else {
> >        if(hex(asc) != "00") {
> >           RetStr = StringConcatenate(RetStr,"%",hex(asc));
> >        }else{
> >           RetStr = StringConcatenate(RetStr,c);
> >        }
> >      }
> >    }
> >    return (RetStr);
> > }
>
> --
> *HIGH RISK DISCLOSURE:* Foreign exchange trading carries a high level of
> risk that may not be suitable for all investors. Leverage creates
> additional risk and loss exposure. Before you decide to trade foreign
> exchange, carefully consider your investment objectives, experience
> level, and risk tolerance. You could lose some or all of your initial
> investment; do not invest money that you cannot afford to lose. Educate
> yourself on the risks associated with foreign exchange trading, and seek
> advice from an independent financial or tax advisor if you have any
> questions. *ADVISORY WARNING:*Fx1.net provide references and links to
> selected blogs and other sources of economic and market information as
> an educational service to our users and we do not endorse the opinions
> or recommendations of the blogs or other sources of information. Users
> are advised to carefully consider the opinions and analysis offered in
> the blogs or other information sources in the context of the user's
> individual analysis and decision making. None of the blogs or other
> sources of information is to be considered as constituting a track
> record. Past performance is no guarantee of future results and we
> specifically advise users to carefully review all claims and
> representations made by advisors, bloggers, money managers and system
> vendors before investing any funds or opening an account with any Forex
> dealer. Any news, opinions, research, data, or other information
> contained within this website is provided as general market commentary
> and does not constitute investment or trading advice. We expressly
> disclaim any liability for any lost principal or profits without
> limitation which may arise directly or indirectly from the use of or
> reliance on such information. As with all such advisory services, past
> results are never a guarantee of future results. *US CFTC RULE 4.41* -

Fx1 Inc

unread,
May 22, 2012, 11:37:47 AM5/22/12
to mql...@googlegroups.com
On 5/21/2012 12:35 PM, Jos wrote:
I tested this with control variables, and the issue is actually in the
way it changes StringSubStr, not the hex thing.
Jos,



check this out please. I have made a test. Source code looks like this:



As you see source and output are equal to me, also their lenght etc. Do you want to try again maybe you code? Or send me a demo code which may reprocedure this bug please

Thank you for testing ML

Fx1.Net

unread,
May 30, 2012, 8:37:32 AM5/30/12
to mql...@googlegroups.com
Jos, did you have chance to try this issue again please?
Reply all
Reply to author
Forward
0 new messages