|
Separate string into multiple lines
#483517
06/08/21 23:17
06/08/21 23:17
|
Joined: Apr 2021
Posts: 41 Slovakia
tomna1993
OP
Newbie
|
OP
Newbie
Joined: Apr 2021
Posts: 41
Slovakia
|
Hi, I have a long string which I use for formatting data I want to save. It looks like this: string LogDataFormat = "%s,%i,%s,%i,%.15f,%.15f,%i,%i,%.2f,%.2f,%.2f,%.2f,%.2f,%.2f,%i,%.2f,%.2f,%.2f,%.2f,%.2f,%i,%.2f,%i,%.2f,%.2f,%.2f,%i,%.2f,%.2f,%i%i,%i,%i%i,%.2f\n"; I want to separate it to multiple rows to be much more readable, if it is possible use comment for each row. I already tried one solution which works in C but the formatting of my data in log file was exactly the same looking as the multirow string: string LogDataFormat = "%s,\
%i,\
%s,\
%i,\
%.15f,%.15f,\
%i,%i,%.2f,%.2f,\
%.2f,%.2f,\
%.2f,%.2f,\
%i,%.2f,\
%.2f,%.2f,\
%.2f,%.2f,\
%i,%.2f,\
%i,%.2f,\
%.2f,%.2f,\
%i,%.2f,\
%.2f,\
%i%i,%i,%i%i,\
%.2f\n"; Is there any solution to format that string much more readable in Lite-c?
|
|
|
Re: Separate string into multiple lines
[Re: tomna1993]
#483529
06/09/21 14:05
06/09/21 14:05
|
Joined: Aug 2017
Posts: 294 Netherlands
Grant
Member
|
Member
Joined: Aug 2017
Posts: 294
Netherlands
|
OK, can you try this?
string LogDataFormat = "%s,\n\ %i,\n\ %s,\n\ %i,\n\ %.15f,%.15f,\n\ %i,%i,%.2f,%.2f,\n\ %.2f,%.2f,\n\ %.2f,%.2f,\n\ %i,%.2f,\n\ %.2f,%.2f,\n\ %.2f,%.2f,\n\ %i,%.2f,\n\ %i,%.2f,\n\ %.2f,%.2f,\n\ %i,%.2f,\n\ %.2f,\n\ %i%i,%i,%i%i,\n\ %.2f\n";
(or else LogDataFormat as char*)
Last edited by Grant; 06/09/21 14:50.
|
|
|
Re: Separate string into multiple lines
[Re: Grant]
#483533
06/10/21 08:51
06/10/21 08:51
|
Joined: Apr 2021
Posts: 41 Slovakia
tomna1993
OP
Newbie
|
OP
Newbie
Joined: Apr 2021
Posts: 41
Slovakia
|
I use file append to add information to the txt file. file_append(LogDestination, LogHeader, 0)
file_append(LogDestination, LogData, 0) And use the formatting to save the informations formatted to LogData String. strcat(LogData, strf(LogDataFormat, (string)Log_Asset,
(int)TradeID,
(string)Log_TradeDirection,
(int)Log_TradeTimeFrame,
(var)TradeDate,
(var)TradeExitDate,
(int)TradeBars,
(int)Lots,
(var)TradePriceOpen,
));
|
|
|
|