Gamestudio Links
Zorro Links
Newest Posts
Data from CSV not parsed correctly
by EternallyCurious. 04/18/24 10:45
StartWeek not working as it should
by Zheka. 04/18/24 10:11
folder management functions
by VoroneTZ. 04/17/24 06:52
lookback setting performance issue
by 7th_zorro. 04/16/24 03:08
zorro 64bit command line support
by 7th_zorro. 04/15/24 09:36
Zorro FIX plugin - Experimental
by flink. 04/14/24 07:48
Zorro FIX plugin - Experimental
by flink. 04/14/24 07:46
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (EternallyCurious, howardR), 646 guests, and 0 spiders.
Key: Admin, Global Mod, Mod
Newest Members
EternallyCurious, 11honza11, ccorrea, sakolin, rajesh7827
19046 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
Separate string into multiple lines #483517
06/08/21 23:17
06/08/21 23:17
Joined: Apr 2021
Posts: 41
Slovakia
T
tomna1993 Offline OP
Newbie
tomna1993  Offline OP
Newbie
T

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:
Code
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:

Code
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] #483519
06/09/21 07:27
06/09/21 07:27
Joined: May 2015
Posts: 390
Czech Republic
G
Grat Offline
Senior Member
Grat  Offline
Senior Member
G

Joined: May 2015
Posts: 390
Czech Republic
mayby:
Code
string LogDataFormat = "%s,
%i,
%s,
%i,
..
%.2f";

Re: Separate string into multiple lines [Re: Grat] #483521
06/09/21 07:56
06/09/21 07:56
Joined: Apr 2021
Posts: 41
Slovakia
T
tomna1993 Offline OP
Newbie
tomna1993  Offline OP
Newbie
T

Joined: Apr 2021
Posts: 41
Slovakia
Already tried it, does not work.

Re: Separate string into multiple lines [Re: tomna1993] #483524
06/09/21 09:27
06/09/21 09:27
Joined: Aug 2017
Posts: 294
Netherlands
G
Grant Offline
Member
Grant  Offline
Member
G

Joined: Aug 2017
Posts: 294
Netherlands
Replace the string type with char* in your second code example.

Re: Separate string into multiple lines [Re: Grant] #483526
06/09/21 10:01
06/09/21 10:01
Joined: Apr 2021
Posts: 41
Slovakia
T
tomna1993 Offline OP
Newbie
tomna1993  Offline OP
Newbie
T

Joined: Apr 2021
Posts: 41
Slovakia
It still gives the same result.

I think I wrongly described my problem. The code I included works nice in a manner of code readability but in my log file it looks like on the attached picture. I want to log each trade in separate rows and also print a header for my file in one row like a csv document (see picture). The problem is, that the code I included in the first post puts each word in new row and puts a "\r" characters after the comma.

Attached Files Annotation 2021-06-09 115945.pngAnnotation 2021-06-09 120821.png
Last edited by tomna1993; 06/09/21 10:08.
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
G
Grant Offline
Member
Grant  Offline
Member
G

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] #483530
06/09/21 20:55
06/09/21 20:55
Joined: Apr 2021
Posts: 41
Slovakia
T
tomna1993 Offline OP
Newbie
tomna1993  Offline OP
Newbie
T

Joined: Apr 2021
Posts: 41
Slovakia
Same result.

Re: Separate string into multiple lines [Re: tomna1993] #483531
06/09/21 21:50
06/09/21 21:50
Joined: Aug 2017
Posts: 294
Netherlands
G
Grant Offline
Member
Grant  Offline
Member
G

Joined: Aug 2017
Posts: 294
Netherlands
Sorry to hear. I've tried the following simple example that works fine, but I have no clue on how you've implemented this LogDataFormat string, so can you show me your code?

char* LogDataFormat = "Trade 1.\n\Trade 2.\n\Trade 3.";
print(TO_CSV, LogDataFormat);

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
T
tomna1993 Offline OP
Newbie
tomna1993  Offline OP
Newbie
T

Joined: Apr 2021
Posts: 41
Slovakia
I use file append to add information to the txt file.
Code
file_append(LogDestination, LogHeader, 0)
file_append(LogDestination, LogData, 0)

And use the formatting to save the informations formatted to LogData String.
Code
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, 
));

Re: Separate string into multiple lines [Re: tomna1993] #483549
06/14/21 07:13
06/14/21 07:13
Joined: Jul 2000
Posts: 27,978
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,978
Frankfurt
If I understand it right, you want the format string to go over several lines in your source code, but behave as if it were a single line.

I think this won't work in lite-C. You can do it with #defines, but not with strings.

Page 1 of 2 1 2

Moderated by  Petra 

Powered by UBB.threads™ PHP Forum Software 7.7.1