Is there a Characters replacement in a string function?

Questions about MultiCharts and user contributed studies.
arjfca
Posts: 1283
Joined: 23 Nov 2010
Has thanked: 724 times
Been thanked: 222 times

Is there a Characters replacement in a string function?

Postby arjfca » 23 May 2013

Hello

Is there a function to replace characters in a string.
I need to remove ":" and the "." in a time string like 06:30:37.957

Martin

User avatar
TJ
Posts: 7176
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 990 times
Been thanked: 2049 times

Re: Is there a Characters replacement in a string function?

Postby TJ » 23 May 2013

Hello

Is there a function to replace characters in a string.
I need to remove ":" and the "." in a time string like 06:30:37.957

Martin
Probably there is a function to do the trick; I haven't came across it yet.


To remove the characters, you have to:

1. find out the length of the string,
2. run a loop to cycle through the length of the string,
3. at each cycle, check to see if the successive character of the string is a ":" or ".",
4. if not, then add the character to the "new" string,
5. if so, then skip the character and go on to the next one.
6. at the end of the loop, you will have the new string without the ":" or "." .

SP
Posts: 453
Joined: 06 Feb 2006
Has thanked: 36 times
Been thanked: 283 times

Re: Is there a Characters replacement in a string function?

Postby SP » 23 May 2013

Martin,
FormatTime("HHmmss",datetime) or
FormatTime("HHmmss",el_timetodatetime_s (time_s)) returns 063037 as string.

FormatTime("hhmmssms", datetime)) returns 063037957 with Milliseconds.


Return to “MultiCharts”