Gamestudio Links
Zorro Links
Newest Posts
loading historical data 1st time
by AndrewAMD. 04/14/23 12:54
Trade at bar open
by juanex. 04/13/23 19:43
Bug in Highpass2 filter
by rki. 04/13/23 09:54
Adding Limit Orders For IB
by scatters. 04/11/23 16:16
FisherN
by rki. 04/11/23 08:38
AUM Magazine
Latest Screens
SHADOW (2014)
DEAD TASTE
Tactics of World War I
Hecknex World
Who's Online Now
4 registered members (AndrewAMD, fogman, Grant, juanex), 972 guests, and 7 spiders.
Key: Admin, Global Mod, Mod
Newest Members
rki, FranzIII, indonesiae, The_Judge, storrealba
18919 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 Offline
Senior Member
Dico  Offline
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