www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - temp file

reply bioinfornatics <bioinfornatics fedoraproject.org> writes:
hi,
when i try to use tmpfile from std.stdio i get this error
 char 0x00ad not allowed in identifier
I use dmdfe 2.058, i do just: File tmp =3D tmpfile();
Feb 17 2012
parent reply Denis Shelomovskij <verylonglogin.reg gmail.com> writes:
18.02.2012 6:59, bioinfornatics пишет:
 hi,
 when i try to use tmpfile from std.stdio i get this error
 char 0x00ad not allowed in identifier
I use dmdfe 2.058, i do just: File tmp = tmpfile();
Full source, please. And you should use `File.tmpfile()` instead of `tmpfile()` (unless you are already in `with(File)`?). This compiles: --- import std.stdio; void main() { with(File) File tmp = tmpfile(); } --- Anyway, 0x00ad is 'SOFT HYPHEN' (not a '_' char) and is valid but ignorable in a Java identifier. Looks like your editor added it. http://www.fileformat.info/info/unicode/char/ad/index.htm By the way, you just inspired me to fill this: http://d.puremagic.com/issues/show_bug.cgi?id=7537
Feb 18 2012
parent reply bioinfornatics <bioinfornatics fedoraproject.org> writes:
Le samedi 18 f=C3=A9vrier 2012 =C3=A0 12:58 +0400, Denis Shelomovskij a =C3=
=A9crit :
 18.02.2012 6:59, bioinfornatics =D0=BF=D0=B8=D1=88=D0=B5=D1=82:
 hi,
 when i try to use tmpfile from std.stdio i get this error
 char 0x00ad not allowed in identifier
I use dmdfe 2.058, i do just: File tmp =3D tmpfile();
=20 Full source, please. And you should use `File.tmpfile()` instead of=20 `tmpfile()` (unless you are already in `with(File)`?). This compiles: --- import std.stdio; =20 void main() { with(File) File tmp =3D tmpfile(); } --- =20 Anyway, 0x00ad is 'SOFT HYPHEN' (not a '_' char) and is valid but=20 ignorable in a Java identifier. Looks like your editor added it. http://www.fileformat.info/info/unicode/char/ad/index.htm =20 By the way, you just inspired me to fill this: http://d.puremagic.com/issues/show_bug.cgi?id=3D7537
thanks is was mine stupid error. Then now i have this: -------------------------- cat tmp.d import std.string; import std.stdio; void main( ){ File tmp =3D File.tmpfile(); tmp.writeln( "ok" ); tmp.writeln( "D is Fun" ); writefln( "fileName: %s", tmp.name ); foreach( line; tmp.byLine() ) writefln( "l: %s", line ); } -------------------------- $ ./tmp fileName:=20 -------------------------- Why i do not get the file name ? why i can not iterate over line?
Feb 18 2012
parent "HeiHon" <heiko.honrath gmx.de> writes:
On Saturday, 18 February 2012 at 10:19:06 UTC, bioinfornatics 
wrote:
 import std.string;
 import std.stdio;

 void main(  ){
     File tmp = File.tmpfile();
     tmp.writeln( "ok" );
     tmp.writeln( "D is Fun" );
     writefln( "fileName: %s", tmp.name );
     foreach( line; tmp.byLine() )
         writefln( "l: %s", line );
 }
...
 why i can not iterate over line?
You can, but the file is still open and you are at the end of the file. Try: tmp.rewind; foreach( line; tmp.byLine() ) writefln( "l: %s", line );
Feb 18 2012