Gamestudio Links
Zorro Links
Newest Posts
Trading Journey
by M_D. 04/26/24 20:22
Help with plotting multiple ZigZag
by M_D. 04/26/24 20:03
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
Zorro FIX plugin - Experimental
by flink. 04/21/24 07:12
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (AndrewAMD), 839 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
wandaluciaia, Mega_Rod, EternallyCurious, howardR, 11honza11
19049 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Strange string behavious within loop #466928
07/09/17 01:09
07/09/17 01:09
Joined: Jun 2017
Posts: 78
B
BobbyT Offline OP
Junior Member
BobbyT  Offline OP
Junior Member
B

Joined: Jun 2017
Posts: 78
Hi all,

I have been working on a version of the scripts from pcz that are compatible with Zorro F (free). If your interested they are here (http://www.opserver.de/ubb7/ubbthreads.php?ubb=showflat&Number=459580#Post459580) though looking into them isn't necessary to understand the issue at hand.

The minimal example below is meant to take Asset and a start and end date and print file names generated from these variables. It does this faithfully for 2 iterations of the loop then the inName/outName variables start to contatenate on themselves.

Included in the code are two alternatives to handling the loop and two alternative to handle the string creation. If using the while() loop, the iterator is @ line 46 (y1 += 1).

Code:
//minimal working example of the file name creation error 
#define M1
#include <default.c>
#include <stdio.h>

//externs & inputs
// already should contain ticks in reversed order
string basePath = "E:FxData_SQ"; //can be anything, does not alter the result as no files are accessed at this stage
int start = 2007;
int end = 2010;

//functions
void createFileNames(int startYear, int endYear, string smbl)
{
	printf("nentered createFileNames");	
	int y1;				//for for() loop
	//int y1 = start; //for while() loop
		
	for(y1 = start; y1 <= end; y1++)
	//while(y1 <= end)
	{
		//string symbol = smbl; //forcing smbl to be stored in another variable does not fix the issue
		printf("nnProcessing year %d...for symbol %s...", y1, smbl);
		
		//test #1
		char inName[256];
		char outName[256];

		sprintf(inName, "%s%s_%d.csv", basePath, smbl, y1);
		sprintf(outName, "%s%s_%d.t6", basePath, smbl, y1);
		file_delete(outName);
		
		//test #2, inName and outName do not seem to obey intialisation, concatenate on themselves)
		/*string inName = "";
		string outName = "";

		inName = strf("%s%s_%d.csv", basePath, smbl, y1);
		outName = strf("%s%s_%d.t6", basePath, smbl, y1);
		file_delete(outName); 
		//end test #1
		*/		
		
		printf("nIn File: %s", inName);
		printf("nOut File: %s", outName);

		//y1 += 1;	//needed for while() loop
		
		Sleep(5000);
	}
}

//main 
function main()
{
	printf("nmain started");
	
	string smbl = strx(Asset, "/", "");
	printf("nMain() smbl = %s", smbl);
	
	#ifdef M1
		{ printf("nM1 defined, creating file names for %s", smbl);
		  createFileNames(start, end, smbl); }
	#endif
	
}



Any suggestions?

Cheers,
BobbyT

Last edited by BobbyT; 07/09/17 01:11.
Re: Strange string behavious within loop [Re: BobbyT] #466932
07/09/17 19:11
07/09/17 19:11
Joined: May 2016
Posts: 180
Prague
pcz Offline
Member
pcz  Offline
Member

Joined: May 2016
Posts: 180
Prague
I think I don't experience such issue (when filling in the missing backslashes which were removed by the forum system).

My output:

Code:
Processing year 2007...for symbol CHFJPY...
In File: E:\FxData_SQ\CHFJPY_2007.csv
Out File: E:\FxData_SQ\CHFJPY_2007.t6
Processing year 2008...for symbol CHFJPY...
In File: E:\FxData_SQ\CHFJPY_2008.csv
Out File: E:\FxData_SQ\CHFJPY_2008.t6
Processing year 2009...for symbol CHFJPY...
In File: E:\FxData_SQ\CHFJPY_2009.csv
Out File: E:\FxData_SQ\CHFJPY_2009.t6
Processing year 2010...for symbol CHFJPY...
In File: E:\FxData_SQ\CHFJPY_2010.csv
Out File: E:\FxData_SQ\CHFJPY_2010.t6


Re: Strange string behavious within loop [Re: pcz] #466933
07/09/17 20:59
07/09/17 20:59
Joined: Jun 2017
Posts: 78
B
BobbyT Offline OP
Junior Member
BobbyT  Offline OP
Junior Member
B

Joined: Jun 2017
Posts: 78
How odd. After some further testing last night, I found that the issue only arises when the script is run from zorro. It does not ocur when the script is called from the command line.

Inserting
Code:
string smbl = strx(Asset, "/", "");



At the top of the for loop stops the aforementioned behaviour when it is run from zorro.

Regardless, I have some more testing to do today but the scripts are pretty much ready to go. Should I post them in your thread or start a new one?

Cheers,
BobbyT

PS: good catch on the directory slashes. I didn't even check. They were there when I put the code in the reply box smirk

Last edited by BobbyT; 07/09/17 21:00.
Re: Strange string behavious within loop [Re: BobbyT] #466960
07/10/17 17:13
07/10/17 17:13
Joined: May 2016
Posts: 180
Prague
pcz Offline
Member
pcz  Offline
Member

Joined: May 2016
Posts: 180
Prague
BobbyT: I suggest posting it in the old thread so everything is together

Re: Strange string behavious within loop [Re: pcz] #466962
07/10/17 17:40
07/10/17 17:40
Joined: Jun 2017
Posts: 78
B
BobbyT Offline OP
Junior Member
BobbyT  Offline OP
Junior Member
B

Joined: Jun 2017
Posts: 78
That's what I was leaning towards anyway but seeing as it's predominately your work I thought I should ask laugh


Moderated by  Petra 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1