Login Page - Create Account

Support Board


Date/Time: Mon, 13 May 2024 04:46:55 +0000



[User Discussion] - Create Time string

View Count: 623

[2020-10-06 13:40:22]
User681150 - Posts: 62
i want to create a standard chart time string 11:35:20 to output to the window log. i have this but cant concatenate to make it a string. can anyone advise how to.. the "time" variable keeps failing

int Hour = sc.BaseDateTimeIn[sc.Index].GetHour();
int Minute = sc.BaseDateTimeIn[sc.Index].GetMinute();
int Second = sc.BaseDateTimeIn[sc.Index].GetSecond();

SCString time = Hour+":"+Minute+":"+Second ;

[2020-10-06 13:54:45]
Ackin - Posts: 1865
i want to create a standard chart time string 11:35:20 to output....the "time" variable keeps failing

try:

SCString ResultText;
SCString time;
SCDateTime CurrentIndex = sc.BaseDateTimeIn[sc.Index];
ResultText.Format("%i:%02i:%02i", CurrentIndex.GetHour(), CurrentIndex.GetMinute(), CurrentIndex.GetSecond());

time+= ResultText;

[2020-10-06 14:38:22]
User681150 - Posts: 62
thats works perfectly. thanks you.

quick question. in your example. you put the Result variable into another variable using += ... why?
[2020-10-06 15:01:40]
Ackin - Posts: 1865
Just to show you how to work with the string if you want to combine it with something else. At the top (in your first post) you mix numbers with characters.

To post a message in this thread, you need to log in with your Sierra Chart account:

Login

Login Page - Create Account