Gamestudio Links
Zorro Links
Newest Posts
Data from CSV not parsed correctly
by jcl. 04/26/24 11:18
M1 Oversampling
by jcl. 04/26/24 11:12
Why Zorro supports up to 72 cores?
by jcl. 04/26/24 11:09
Eigenwerbung
by jcl. 04/26/24 11:08
MT5 bridge not working on MT5 v. 5 build 4160
by EternallyCurious. 04/25/24 20:49
Trading Journey
by howardR. 04/24/24 20:04
Zorro FIX plugin - Experimental
by flink. 04/21/24 07:12
Scripts not found
by juergen_wue. 04/20/24 18:51
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
4 registered members (AndrewAMD, EternallyCurious, Petra, 1 invisible), 764 guests, and 4 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Mega_Rod, EternallyCurious, howardR, 11honza11, ccorrea
19048 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,986
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,986
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