Gamestudio Links
Zorro Links
Newest Posts
Zorro 2.70
by jcl. 09/29/25 09:24
optimize global parameters SOLVED
by dBc. 09/27/25 17:07
ZorroGPT
by TipmyPip. 09/27/25 10:05
assetHistory one candle shift
by jcl. 09/21/25 11:36
Plugins update
by Grant. 09/17/25 16:28
AUM Magazine
Latest Screens
Rocker`s Revenge
Stug 3 Stormartillery
Iljuschin 2
Galactic Strike X
Who's Online Now
4 registered members (AndrewAMD, TipmyPip, NewbieZorro, Grant), 14,196 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
krishna, DrissB, James168, Ed_Love, xtns
19168 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
opening files #422848
05/18/13 14:57
05/18/13 14:57
Joined: Nov 2012
Posts: 126
B
blaub4r Offline OP
Member
blaub4r  Offline OP
Member
B

Joined: Nov 2012
Posts: 126
I tried to open a file in a Zorro script using this code:

// -----------------------------------
#include <stdio.h>
bool schalter1 = false;
bool schalter2 = false;
FILE *pf;

function run()
{
if (!schalter1)
{
schalter1 = true;
pf = fopen("D:\Zorro\Log\test.txt","w");
}

var *Price = series(price());
var *Trend = series(LowPass(Price,1000));
var *Signals = series(0);

Stop = 4*ATR(100);
if (year(0) == 2013 && !schalter2)
{
msg("%f",pf);
schalter2 = true;
fprintf("Hallo",pf);
fclose(pf);
}
}
// -----------------------------------------

But it does not work as 0 is assigned to pf which means there was an error while opening the file.
Can someone help me with that?

Re: opening files [Re: blaub4r] #422849
05/18/13 15:26
05/18/13 15:26
Joined: May 2013
Posts: 23
Somewhere
W
Wiseguy Offline
Newbie
Wiseguy  Offline
Newbie
W

Joined: May 2013
Posts: 23
Somewhere
You need to escape the '\' character. The correct path would be "D:\\Zorro\\Log\\test.txt". Also make sure that you have write access to the path.


His words are wise, his face is beard.
Re: opening files [Re: Wiseguy] #422850
05/18/13 16:28
05/18/13 16:28
Joined: Nov 2012
Posts: 126
B
blaub4r Offline OP
Member
blaub4r  Offline OP
Member
B

Joined: Nov 2012
Posts: 126
Ok, thanks, this seemed to be part of the problem. Now the file is created but it remains empty.
And I think I do have write access as Zorro writes his own logs there, too.

Re: opening files [Re: blaub4r] #422860
05/19/13 01:01
05/19/13 01:01
Joined: Feb 2012
Posts: 371
Dico Online
Senior Member
Dico  Online
Senior Member

Joined: Feb 2012
Posts: 371
change this line pf = fopen("D:\Zorro\Log\test.txt","w"); by this

pf = fopen("D:/Zorro/Log/test.txt","w");

Re: opening files [Re: Dico] #422871
05/19/13 08:09
05/19/13 08:09
Joined: May 2013
Posts: 23
Somewhere
W
Wiseguy Offline
Newbie
Wiseguy  Offline
Newbie
W

Joined: May 2013
Posts: 23
Somewhere
@Dico: While the underlying API to resolve filenames does support Unix style file separators, it's not recommended to use them.

@blaub4r: Check the declaration of the fprintf() function, especially the signature wink


His words are wise, his face is beard.
Re: opening files [Re: Wiseguy] #422874
05/19/13 09:50
05/19/13 09:50
Joined: Nov 2012
Posts: 126
B
blaub4r Offline OP
Member
blaub4r  Offline OP
Member
B

Joined: Nov 2012
Posts: 126
Originally Posted By: Wiseguy

@blaub4r: Check the declaration of the fprintf() function, especially the signature wink

Thank you, I got it now laugh


Moderated by  Petra 

Powered by UBB.threads™ PHP Forum Software 7.7.1