what is the difference of "\t" and '\t' ? - page 2

 
gooly:

Well to me it's still funny.

I join a string by:

but I can't split this string using "\t" with which I glue the items together?



I understand what you are saying. You would like string split to have been implemented as StringSplit(string,string,string &[]) rather than a single char for splitting. There may be some merit in that point of view. (more versatile and yet 'simpler' for non-coders), But MQL have not implemented it that way.

If you really want to make you own StringSplit(string,string,string &[]) that makes you happy, you could probably combine StringReplace and StringSplit but it will need to be careful!

 

or you can build your own function

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

 
qjol:

or you can build your own function

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


Now we have StringReplace and StringSplit it would be much simpler, and faster to use

// not real code - error handling and selection of USHORT separator ommitted to etc. 

int MyStringSplit(string in,string sep,string &out[]) {

    StringReplace(in,sep, string form of SOME_USHORT_NOT_IN_STRING);

    return StringSplit(in, SOME_USHORT_NOT_IN_STRING,out);

}
 

I wrote, "or you can build your own function" It's up to him

personally i prefer not to change the source string, and leave it as is (by using StringReplace you are changing the source), just to use a copy (string& Out[])

but again, each one with is personal preference

 

qjol I wrote, "or you can build your own function"

I didnt quite get the 'or' because I was also suggesting the same thing -

[me]If you really want to make you own StringSplit ...

[you]or build your own function'

[me]huh??

It would have made more sense to me if your post read 'or you can do it like this'.

qjol: personally i prefer not to change the source string, and leave it as is

It would not change the source because 'in' is is pass by value in

int MyStringSplit(string in,string sep,string &out[]) 

For clarity you could simply assign 'in' to another string 'inCopy'.

I'd rather a two line function calling built- in functions than the alternative implementation which will be slower and potentially makes many calls to ArrayResize (although there are ways around that, esp with the new ArrayResize), but like you say, personal preference :)

Also I've ommited the check to ensure that USHORT is not already in the original string. So maybe it will end up about 6 lines


Also the last parameter in StringSubstr is changed in MQL4++ so the linked function will need modifying. But that's quite simple once one is aware of it.

 
Simon Gniadkowski:

I think . . .

"\t" is a string

'\t' is a character ASCII 9

. . . I could be wrong though.

Where can we find the conversion table??? where it shows \t next to tab??
 
NeeZo_NeeZO: Where can we find the conversion table??? where it shows \t next to tab??
The page on strings (String Type - Data Types - Language Basics - MQL4 Reference) second paragraph contains the link directly to Character Constants - Integer Types - Data Types - Language Basics - MQL4 Reference
Reason: