Gamestudio Links
Zorro Links
Newest Posts
Lapsa's very own thread
by Lapsa. 06/08/26 22:41
Stooq now requires an API key
by VHX. 06/08/26 20:14
ZorroGPT
by TipmyPip. 06/06/26 12:36
Zorro 3.01 recoded MMI function issue
by TipmyPip. 06/04/26 05:44
SGT_FW
by Aku_Aku. 05/31/26 11:05
Issues resuming trades on Demo account
by Martin_HH. 05/22/26 13:31
XTB
by pr0logic. 05/18/26 12:27
AUM Magazine
Latest Screens
Dorifto samurai
Shadow 2
Rocker`s Revenge
Stug 3 Stormartillery
Who's Online Now
1 registered members (TipmyPip), 3,506 guests, and 6 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Seraphinang, Koti, curry, DeepxKalsi, Samed
19219 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