Gamestudio Links
Zorro Links
Newest Posts
MT5 bridge not working on MT5 v. 5 build 4160
by EternallyCurious. 04/25/24 20:49
Data from CSV not parsed correctly
by EternallyCurious. 04/25/24 10:20
Trading Journey
by howardR. 04/24/24 20:04
M1 Oversampling
by Petra. 04/24/24 10:34
Zorro FIX plugin - Experimental
by flink. 04/21/24 07:12
Scripts not found
by juergen_wue. 04/20/24 18:51
zorro 64bit command line support
by 7th_zorro. 04/20/24 10:06
StartWeek not working as it should
by jcl. 04/20/24 08:38
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (AndrewAMD), 827 guests, and 6 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
Enumerate with file_next over filenames in directory #484884
12/25/21 16:44
12/25/21 16:44
Joined: Dec 2021
Posts: 7
B
budfox Offline OP
Newbie
budfox  Offline OP
Newbie
B

Joined: Dec 2021
Posts: 7
Hi,

currently I am trying to modify the script CSVtoHistory and transform multiple csv files at the same time.

In the manual I found the method file_next(string name) to access the filenames in a directory. The description points out that it can be used to loop well over the filenames in a directory.

Unfortunately, I haven't figured out how to access the next filename in each case, but always get only the first filename in the directory. Does anyone have a suggestion for a solution?

See below my current attempt to get the filenames...


Code

function main() 
{
	int i;
	for (i = 0; i < 10; i++) {
	
	string Name = file_next("CollectedHistory\\*.csv");
	printf("Der Filename lautet: %s \n", Name);
	
	}
}


Re: Enumerate with file_next over filenames in directory [Re: budfox] #484885
12/25/21 17:20
12/25/21 17:20
Joined: Dec 2021
Posts: 7
B
budfox Offline OP
Newbie
budfox  Offline OP
Newbie
B

Joined: Dec 2021
Posts: 7
I figured it out after trying some more and thought that might be of interest to others.

Code
function main() 
{
	int i;
	for (i = 0; i < 10; i++) {
		
		printf("i ist %i", i);
		if (i == 0) {
			string Name = file_next("CollectedHistory\\*.csv");
			printf("Der Filename lautet: %s \n", Name);
		} 
		else {
			string Name = file_next(0);
			printf("Der Filename lautet: %s \n", Name);
		}
		
	}
}

Re: Enumerate with file_next over filenames in directory [Re: budfox] #485615
03/31/22 11:35
03/31/22 11:35
Joined: Mar 2022
Posts: 17
Frankfurt am Main
B
BrainSailor Offline
Newbie
BrainSailor  Offline
Newbie
B

Joined: Mar 2022
Posts: 17
Frankfurt am Main
Thanks for sharing! I was having the same issue! 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