Jump to page: 1 2
Thread overview
FIle I/O
Sep 16, 2010
Graham Nicholls
Sep 16, 2010
Tom Kazimiers
Sep 16, 2010
Graham Nicholls
Sep 16, 2010
Graham Nicholls
Sep 16, 2010
Tom Kazimiers
Sep 16, 2010
Kagamin
Sep 16, 2010
Jonathan M Davis
Sep 17, 2010
Graham Nicholls
Sep 17, 2010
Jonathan M Davis
Sep 18, 2010
Graham Nicholls
Sep 18, 2010
Jonathan M Davis
Sep 16, 2010
Nick Sabalausky
September 16, 2010
I'm writing a program to take a file and convert it into a binary format which
matches the format produced by a system which we use.  If I get it right, this
will allow me to "replay" the file into the system.  However I can't find how
to do I/O in D.  I've got the "D Programming Language" and "Tango" books, but
not much there, and as a C/C++ programmer, Tango doesn't seem that appealing
:-).  Is there a tutorial anywhere?
Thanks
September 16, 2010
Hi Graham,

On 09/16/2010 04:28 PM, Graham Nicholls wrote:
> I'm writing a program to take a file and convert it into a binary format which matches the format produced by a system which we use.  If I get it right, this will allow me to "replay" the file into the system.  However I can't find how to do I/O in D.  I've got the "D Programming Language" and "Tango" books, but not much there, and as a C/C++ programmer, Tango doesn't seem that appealing :-).  Is there a tutorial anywhere?

in case you did not find some example code yet: http://www.dprogramming.com/FileTutorial.html

Regards,
Tom
September 16, 2010
Thanks.  Not sure how I didn't find that - I'm looking now. Graham
September 16, 2010
Is this D 1.0 ? I get errors regarding printf - I understood that writeln was the
2.0 way.
Thanks
September 16, 2010
Graham,

On 09/16/2010 05:02 PM, Graham Nicholls wrote:
> Is this D 1.0 ? I get errors regarding printf - I understood that writeln was the 2.0 way.

Yes, I think it's D 1.0. For a D 2.0 version I replaced those printf's with writeln's, too.

Bye,
Tom
September 16, 2010
"Graham Nicholls" <graham@rockcons.co.uk> wrote in message news:i6t9ig$1ffs$1@digitalmars.com...
> I'm writing a program to take a file and convert it into a binary format
> which
> matches the format produced by a system which we use.  If I get it right,
> this
> will allow me to "replay" the file into the system.  However I can't find
> how
> to do I/O in D.  I've got the "D Programming Language" and "Tango" books,
> but
> not much there, and as a C/C++ programmer, Tango doesn't seem that
> appealing
> :-).  Is there a tutorial anywhere?
> Thanks

File/path I/O is kind of a pain in Tango. You might want to consider D2/Phobos for that: http://www.digitalmars.com/d/2.0/phobos/std_file.html

If you want to use D1/Tango though, the API reference is here: http://www.dsource.org/projects/tango/docs/stable


September 16, 2010
Tom Kazimiers Wrote:

> Hi Graham,
> 
> On 09/16/2010 04:28 PM, Graham Nicholls wrote:
> > I'm writing a program to take a file and convert it into a binary format which matches the format produced by a system which we use.  If I get it right, this will allow me to "replay" the file into the system.  However I can't find how to do I/O in D.  I've got the "D Programming Language" and "Tango" books, but not much there, and as a C/C++ programmer, Tango doesn't seem that appealing :-).  Is there a tutorial anywhere?
> 
> in case you did not find some example code yet: http://www.dprogramming.com/FileTutorial.html
> 
> Regards,
> Tom

Weren't streams converted to ranges?
September 16, 2010
On Thursday, September 16, 2010 13:16:03 Kagamin wrote:
> Tom Kazimiers Wrote:
> > Hi Graham,
> > 
> > On 09/16/2010 04:28 PM, Graham Nicholls wrote:
> > > I'm writing a program to take a file and convert it into a binary format which matches the format produced by a system which we use.  If I get it right, this will allow me to "replay" the file into the system.  However I can't find how to do I/O in D.  I've got the "D Programming Language" and "Tango" books, but not much there, and as a C/C++ programmer, Tango doesn't seem that appealing
> > > 
> > > :-).  Is there a tutorial anywhere?
> > 
> > in case you did not find some example code yet: http://www.dprogramming.com/FileTutorial.html
> > 
> > Regards,
> > Tom
> 
> Weren't streams converted to ranges?

Not yet. std.stream as it is is going to be deprecated/removed. However, the Phobos team does not yet have a replacement for it (which will be a range-based stream solution). I believe that there's at least one implementation floating around which might make it into Phobos, but nothing has been approved yet for inclusion.

- Jonathan M Davis
September 17, 2010
I'm getting a little confused.  I've installed a .deb package of d 2.0, but now my
code won't compile:
unlogcat.d(112): Error: std.stream.File at
/usr/include/d/dmd/phobos/std/stream.d(1787) conflicts with std.stdio.File at
/usr/include/d/dmd/phobos/std/stdio.d(248)

Yet if I leave either out, I get unresolved symbols.  Also, where can I find out
what exceptions can be raised for a particular operation ?
Thanks
September 17, 2010
On Fri, 17 Sep 2010 12:21:07 -0400, Graham Nicholls <graham@rockcons.co.uk> wrote:

> I'm getting a little confused.  I've installed a .deb package of d 2.0, but now my
> code won't compile:
> unlogcat.d(112): Error: std.stream.File at
> /usr/include/d/dmd/phobos/std/stream.d(1787) conflicts with std.stdio.File at
> /usr/include/d/dmd/phobos/std/stdio.d(248)
>
> Yet if I leave either out, I get unresolved symbols.  Also, where can I find out
> what exceptions can be raised for a particular operation ?
> Thanks

Your code probably is including both stdio and stream.  Then you use the simple type File, which is defined in both.

Try disambiguating by using std.stdio.File or std.stream.File.

Or alternatively, you can rename imports (don't remember the exact syntax).

-Steve
« First   ‹ Prev
1 2