PureBytes Links
Trading Reference Links
|
As you will see from my most recent post, that has no effect on the
problem.
Bill
--- In amibroker@xxxxxxxxxxxxxxx, "Steve Dugas" <sjdugas@xxxx> wrote:
> Possibly because your test for fh is inside a set of brackets, it is
treated
> as a seperate local variable? I might try moving it outside the
brackets,
> something like this:
>
> fh = fopen( filename, "w") ;
> for (j=0; fh AND j<7; j++)
> {
> idx = StrExtract( indexesL , j ) ;
> if ( Name() == "^"+StrExtract( indexesU , j ) )
> {
> idx = StrExtract( indexesL , j ) ;
> s = StrFormat( ",%f\n", LastValue(Highest( ATR( 1 ) ) ) ) ;
> fputs(idx + s, fh ) ;
> }
> }
> fclose(fh) ;
>
>
> ----- Original Message -----
> From: "bilbo0211" <bilbod@xxxx>
> To: <amibroker@xxxxxxxxxxxxxxx>
> Sent: Monday, June 27, 2005 8:14 PM
> Subject: [amibroker] Possible File I/O bug.
>
>
> >I am having a problem with file I/O. I don't know if it is a bug or
I
> > am doing something I am not supposed to do.
> >
> > If I open a file and write to it multiple times in a loop, there
is no
> > error but the file is always empty. If I use the same code except
open
> > and close the file each time I write to it in the loop, the file
> > contains the correct data.
> >
> > What follows are 2 pieces of code that demonstrates the problem.
1st
> > is the one that gives the empty file, them the one that gives the
> > correct data.
> >
> > Bill
> > ---
> > Buy=0;
> > Sell=0;
> > indexesL = "dji,ixic,ndx,rut,spx,vay,vlic" ;
> > indexesU = "DJI,IXIC,NDX,RUT,SPX,VAY,VLIC" ;
> >
> > filename = "d:\\tmp\\amibroker\\cycles\\highest_tr.dat" ;
> > fh = fopen( filename, "w") ;
> > for (j=0; j<7; j++)
> > {
> > idx = StrExtract( indexesL , j ) ;
> > if ( Name() == "^"+StrExtract( indexesU , j ) )
> > {
> > idx = StrExtract( indexesL , j ) ;
> > s = StrFormat( ",%f\n", LastValue(Highest( ATR( 1 ) ) ) ) ;
> > if(fh)
> > {
> > fputs(idx + s, fh ) ;
> > }
> > }
> > }
> > fclose(fh) ;
> > ---
> > Buy=0;
> > Sell=0;
> > indexesL = "dji,ixic,ndx,rut,spx,vay,vlic" ;
> > indexesU = "DJI,IXIC,NDX,RUT,SPX,VAY,VLIC" ;
> >
> > filename = "d:\\tmp\\amibroker\\cycles\\highest_tr.dat" ;
> >
> > for (j=0; j<7; j++)
> > {
> > idx = StrExtract( indexesL , j ) ;
> > if ( Name() == "^"+StrExtract( indexesU , j ) )
> > {
> > idx = StrExtract( indexesL , j ) ;
> > s = StrFormat( ",%f\n", LastValue(Highest( ATR( 1 ) ) ) ) ;
> > if (j==0)
> > fh = fopen( filename, "w") ;
> > else
> > fh = fopen( filename, "a") ;
> > if(fh)
> > {
> > fputs(idx + s, fh ) ;
> > fclose(fh) ;
> > }
> > }
> > }
> > ---
> >
> >
> >
> >
> > Please note that this group is for discussion between users only.
> >
> > To get support from AmiBroker please send an e-mail directly to
> > SUPPORT {at} amibroker.com
> >
> > For other support material please check also:
> > http://www.amibroker.com/support.html
> >
> >
> > Yahoo! Groups Links
> >
> >
> >
> >
> >
> >
> >
Please note that this group is for discussion between users only.
To get support from AmiBroker please send an e-mail directly to
SUPPORT {at} amibroker.com
For other support material please check also:
http://www.amibroker.com/support.html
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/amibroker/
<*> To unsubscribe from this group, send an email to:
amibroker-unsubscribe@xxxxxxxxxxxxxxx
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
|