Re: readf with strings

2011-06-23 Thread Kai Meyer
On 06/23/2011 02:27 AM, Dainius (GreatEmerald) wrote: I have a related enhancement request since lot of time: http://d.puremagic.com/issues/show_bug.cgi?id=4716 Bye, bearophile That's exactly what I'd like to see. Voted. After all, D is created with practicality in mind, and doing all that p

Re: readf with strings

2011-06-23 Thread Dainius (GreatEmerald)
> I have a related enhancement request since lot of time: > http://d.puremagic.com/issues/show_bug.cgi?id=4716 > > Bye, > bearophile > That's exactly what I'd like to see. Voted. After all, D is created with practicality in mind, and doing all that parsing is the opposite of what it's trying to a

Re: readf with strings

2011-06-22 Thread bearophile
Ali Çehreli: > "oku" means "read": > > // Read into an existing variable > double d; > oku("Please enter a double: ", &d); > > // Read and return a value > int i = oku!int("Please enter an int: "); I have a related enhancement request since lot of time: http://d.puremagic.co

Re: readf with strings

2011-06-22 Thread Kai Meyer
On 06/22/2011 09:30 AM, Ali Çehreli wrote: On Wed, 22 Jun 2011 14:57:57 +, GreatEmerald wrote: This should be a very elementary question. How do you get a string off stdin? Or an integer, or a boolean, for that matter? If I use this: float MyFloat; string MyString; readf("%f",&MyF

Re: readf with strings

2011-06-22 Thread Ali Çehreli
On Wed, 22 Jun 2011 13:45:56 -0500, Jimmy Cao wrote: > On Wed, Jun 22, 2011 at 1:31 PM, Ali Çehreli wrote: > >> On Wed, 22 Jun 2011 20:17:39 +0200, Andrej Mitrovic wrote: >> >> > This library has some nice user-input methods for D2: >> > https://github.com/he-the-great/JPDLibs/tree/cmdln >> >> T

Re: readf with strings

2011-06-22 Thread Jimmy Cao
On Wed, Jun 22, 2011 at 1:31 PM, Ali Çehreli wrote: > On Wed, 22 Jun 2011 20:17:39 +0200, Andrej Mitrovic wrote: > > > This library has some nice user-input methods for D2: > > https://github.com/he-the-great/JPDLibs/tree/cmdln > > Thanks! :) > > The Turkish D community has experimented with a si

Re: readf with strings

2011-06-22 Thread Andrej Mitrovic
I didn't know there was a Turkish D community. :)

Re: readf with strings

2011-06-22 Thread Ali Çehreli
On Wed, 22 Jun 2011 20:17:39 +0200, Andrej Mitrovic wrote: > This library has some nice user-input methods for D2: > https://github.com/he-the-great/JPDLibs/tree/cmdln Thanks! :) The Turkish D community has experimented with a similar solution: http://ddili.org/forum/post/2960 "oku" means "r

Re: readf with strings

2011-06-22 Thread Ali Çehreli
On Wed, 22 Jun 2011 20:59:46 +0300, Dainius (GreatEmerald) wrote: > I see. Using %s does indeed work with ints, and chomp(readln()) works > with strings. It's rather counter-intuitive, though. There are many counter intuitive bits and imperfect modelling in stream I/ O. For example "42a" is perfe

Re: readf with strings

2011-06-22 Thread Andrej Mitrovic
This library has some nice user-input methods for D2: https://github.com/he-the-great/JPDLibs/tree/cmdln

Re: readf with strings

2011-06-22 Thread Dainius (GreatEmerald)
I see. Using %s does indeed work with ints, and chomp(readln()) works with strings. It's rather counter-intuitive, though. I wonder why there isn't a simpler way to do this, something like writeln() - you could input the variables as parameters and it would automatically read them...

Re: readf with strings

2011-06-22 Thread Ali Çehreli
On Wed, 22 Jun 2011 14:57:57 +, GreatEmerald wrote: > This should be a very elementary question. How do you get a string off > stdin? Or an integer, or a boolean, for that matter? If I use this: > > float MyFloat; > string MyString; > readf("%f", &MyFloat); > writeln(MyFloat); > rea