digitalmars.D.learn - std.stream question
- chojin (54/54) Aug 04 2006 Eck. I am about to pull my hair out. I've been using D for 3 days now an...
- Chris Nicholson-Sauls (25/56) Aug 04 2006 ... etc ...
- chojin (19/22) Aug 04 2006 THANKYOU!
- Robert Atkinson (16/23) Aug 06 2006 I remember when I was just entering University, and the CS department
- Derek (50/116) Aug 04 2006 When working with stdin/stdou/stderr you need to use the std.cstream
Eck. I am about to pull my hair out. I've been using D for 3 days now and can't even get text input on the console going. The first 2 were tied up trying to find a usable decent IDE solution.... others ironing out senseless bugs with no documentation... and I have a computer science degree! Anyway I feel like I could have a big rant but I'll get to the point. I can compile most things just fine, but due to lack of finding decent documentation for scanf I switched over to streams, which seem MUCH nicer... but whenever I try to use them I get errors. Currently trying to use streams using this sample code I got from dsource: import std.stream; import std.string; int main() { char[] input; char[] output; // Ask for a string std.stream.stdout.writeLine("Converts a lowercase string to uppercase."); std.stream.stdout.writeLine("Please enter a string:"); input = std.stream.stdin.readLine(); // Convert to upper and print it output = input.toupper(); std.stream.stdout.writeLine(output); return 0; } And consistently, when using build.exe or dmake or dmd or whatever, I recieve this output: dmd.exe C:\Homes\Administrator\Desktop\D\tester\stringtest.d -debug -g -c -unittest -w -version=OLE_COM C:\Homes\Administrator\Desktop\D\tester\stringtest.d(10): undefined identifier module stream.stdout C:\Homes\Administrator\Desktop\D\tester\stringtest.d(10): undefined identifier module stream.stdout C:\Homes\Administrator\Desktop\D\tester\stringtest.d(10): no property 'writeLine' for type 'void' C:\Homes\Administrator\Desktop\D\tester\stringtest.d(10): function expected before (), not 1 of type int C:\Homes\Administrator\Desktop\D\tester\stringtest.d(11): undefined identifier module stream.stdout C:\Homes\Administrator\Desktop\D\tester\stringtest.d(11): undefined identifier module stream.stdout C:\Homes\Administrator\Desktop\D\tester\stringtest.d(11): no property 'writeLine' for type 'void' C:\Homes\Administrator\Desktop\D\tester\stringtest.d(11): function expected before (), not 1 of type int C:\Homes\Administrator\Desktop\D\tester\stringtest.d(12): undefined identifier module stream.stdin C:\Homes\Administrator\Desktop\D\tester\stringtest.d(12): undefined identifier module stream.stdin Any ideas? I am using the latest dmd.exe and dmc linker tools, etc. I am stumped... regards, Rob
Aug 04 2006
chojin wrote:Eck. I am about to pull my hair out. I've been using D for 3 days now and can't even get text input on the console going. The first 2 were tied up trying to find a usable decent IDE solution.... others ironing out senseless bugs with no documentation... and I have a computer science degree! Anyway I feel like I could have a big rant but I'll get to the point. I can compile most things just fine, but due to lack of finding decent documentation for scanf I switched over to streams, which seem MUCH nicer... but whenever I try to use them I get errors. Currently trying to use streams using this sample code I got from dsource:... code here ...And consistently, when using build.exe or dmake or dmd or whatever, I recieve this output: dmd.exe C:\Homes\Administrator\Desktop\D\tester\stringtest.d -debug -g -c -unittest -w -version=OLE_COM C:\Homes\Administrator\Desktop\D\tester\stringtest.d(10): undefined identifier module stream.stdout identifier module stream.stdin... etc ...Any ideas? I am using the latest dmd.exe and dmc linker tools, etc. I am stumped... regards, RobWell the answer is simple: the example is outdated. Guess I know something I need to fix. ^_^'' The following should be the way to do it with "modern" D. import std.cstream : din, dout ; import std.string : toupper ; int main () { char[] input , output ; // Ask for a string dout.writeLine("Converts a lowercase string to uppercase."); dout.writeLine("Please enter a string:"); input = din.readLine(); // Convert to upper and print it output = input.toupper(); dout.writeLine(output); return 0; } The 'std*' streams are no longer in module 'std.stream' as far as I know. Their roles were usurped by module 'std.cstream' a little ways back, which defines them as instances of the class 'std.cstream.CFile:Stream' and with the names 'din', 'dout', and 'derr'. -- Chris Nicholson-Sauls
Aug 04 2006
"Chris Nicholson-Sauls" <ibisbasenji gmail.com> wrote in message news:eav41r$2ndq$1 digitaldaemon.com...Well the answer is simple: the example is outdated. Guess I know something I need to fix. ^_^'' The following should be the way to do it with "modern" D.THANKYOU! Worked immediately. Please don't take this the wrong way, but I think the problem with D is, of no fault of their own, the community... it seems like everything gets obfuscated and diluted because so many people seem to be putting their 'bit' into it. I must have found six eclipse plugins and by the end of trying to trail which one was the latest I ended up just using batch files and scite. Also, no sign of a simple reference...? The one on digitalmars.com is just a list of function prototypes - what use is that unless you already know the function? The beauty of something like java (which, I don't use, so I'm not some zealot) is that (for console based stuff) there's ONE basic way to output text (System.out.println). It doesn't change and it's reliable. I know D is a young language but unless there's a simple way for newcomers to just download everything they need without DAYS of research, nobody but the most hardcore will use it. Just my input as a newcomer.
Aug 04 2006
chojin wrote: > The beauty of something like java (which, I don't use, so I'm not somezealot) is that (for console based stuff) there's ONE basic way to output text (System.out.println). It doesn't change and it's reliable. I know D is a young language but unless there's a simple way for newcomers to just download everything they need without DAYS of research, nobody but the most hardcore will use it. Just my input as a newcomer.I remember when I was just entering University, and the CS department was going on about this "new" language called Java. So along with my courses in C and Fortran, I took the Java course too. The results? We had to download obscure compilers/IDEs for the coursework and the majority of the textbook was just wrong. The course fell apart for 2 or 3 terms until Java (and its community) matured. The morale of the story is that young languages are like the wild west. The rules are constantly being rewritten, and everyone has to build their own ranch house. Java once was where D is now, and someday, people will be complaining that 'E?' is nowhere near as stable as D. However, unlike Java, when something doesn't work in D (mostly due to my own mis-understanding), I just write it in C and keep on trucking. When Java was borked, you were stuck in Java and all its limitations. R
Aug 06 2006
On Fri, 4 Aug 2006 18:49:53 +1000, chojin wrote:Eck. I am about to pull my hair out. I've been using D for 3 days now and can't even get text input on the console going. The first 2 were tied up trying to find a usable decent IDE solution.... others ironing out senseless bugs with no documentation... and I have a computer science degree! Anyway I feel like I could have a big rant but I'll get to the point. I can compile most things just fine, but due to lack of finding decent documentation for scanf I switched over to streams, which seem MUCH nicer... but whenever I try to use them I get errors. Currently trying to use streams using this sample code I got from dsource: import std.stream; import std.string; int main() { char[] input; char[] output; // Ask for a string std.stream.stdout.writeLine("Converts a lowercase string to uppercase."); std.stream.stdout.writeLine("Please enter a string:"); input = std.stream.stdin.readLine(); // Convert to upper and print it output = input.toupper(); std.stream.stdout.writeLine(output); return 0; } And consistently, when using build.exe or dmake or dmd or whatever, I recieve this output: dmd.exe C:\Homes\Administrator\Desktop\D\tester\stringtest.d -debug -g -c -unittest -w -version=OLE_COM C:\Homes\Administrator\Desktop\D\tester\stringtest.d(10): undefined identifier module stream.stdout C:\Homes\Administrator\Desktop\D\tester\stringtest.d(10): undefined identifier module stream.stdout C:\Homes\Administrator\Desktop\D\tester\stringtest.d(10): no property 'writeLine' for type 'void' C:\Homes\Administrator\Desktop\D\tester\stringtest.d(10): function expected before (), not 1 of type int C:\Homes\Administrator\Desktop\D\tester\stringtest.d(11): undefined identifier module stream.stdout C:\Homes\Administrator\Desktop\D\tester\stringtest.d(11): undefined identifier module stream.stdout C:\Homes\Administrator\Desktop\D\tester\stringtest.d(11): no property 'writeLine' for type 'void' C:\Homes\Administrator\Desktop\D\tester\stringtest.d(11): function expected before (), not 1 of type int C:\Homes\Administrator\Desktop\D\tester\stringtest.d(12): undefined identifier module stream.stdin C:\Homes\Administrator\Desktop\D\tester\stringtest.d(12): undefined identifier module stream.stdin Any ideas? I am using the latest dmd.exe and dmc linker tools, etc. I am stumped... regards, RobWhen working with stdin/stdou/stderr you need to use the std.cstream module... import std.cstream; import std.string; int main() { char[] input; char[] output; // Ask for a string std.cstream.dout.writeLine("Converts a lowercase string to uppercase."); std.cstream.dout.writeLine("Please enter a string:"); input = std.cstream.din.readLine(); // Convert to upper and print it output = input.toupper(); std.cstream.dout.writeLine(output); return 0; } ---- Here is the output I get... c:\temp>type test.d import std.cstream; import std.string; int main() { char[] input; char[] output; // Ask for a string std.cstream.dout.writeLine("Converts a lowercase string to uppercase."); std.cstream.dout.writeLine("Please enter a string:"); input = std.cstream.din.readLine(); // Convert to upper and print it output = input.toupper(); std.cstream.dout.writeLine(output); return 0; } c:\temp>build test Path and Version : z:\util\build.exe v3.02(2207) built on Sat Jun 24 00:44:57 2006 c:\temp>test Converts a lowercase string to uppercase. Please enter a string: kajshdkjhaksdjhakjshdkja KAJSHDKJHAKSDJHAKJSHDKJA c:\temp> -- Derek Parnell Melbourne, Australia "Down with mediocrity!"
Aug 04 2006