[R] Prompt with scan()

Ben Bolker ben at zoo.ufl.edu
Thu Sep 6 14:10:44 CEST 2001


  I was using it for a prompt in my functions that index the CRAN
packages: I have a line

answer <- substr(myreadline("Delete temporary index files (y/N)? "), 1, 1)

(37 characters in the prompt string)
  I wouldn't imagine using readline with a prompt more than 80 characters,
but it's hard to see why it would hurt to make CONSOLE_PROMPT_SIZE equal
to 256, or even 512 ... people always end up using things in ways you
didn't expect, and in this case it seems harmless.

  thanks,
    Ben Bolker

On Thu, 6 Sep 2001, Prof Brian D Ripley wrote:

> On Wed, 5 Sep 2001, Ben Bolker wrote:
>
> >   Do you mean readline()?
> >
> > readline has a 32-character limit, which you can get around as follows:
> >
> >  myreadline <- function(prompt="") {
> >   cat(prompt)
> >   readLines(n=1)
> > }
>
> For the record, that's not the same thing.  Consider the effects of sink().
> Using stderr() would be safer, but not 100% the same.
>
> Is there a real need to raise the 32-char limit?  We can very easily do so
> (or users can: just change
>
> #define CONSOLE_PROMPT_SIZE     32
>
> in src/main/scan.c)  There does need to be a limit though: what do you
> want?
>
>

-- 
318 Carr Hall                                bolker at zoo.ufl.edu
Zoology Department, University of Florida    http://www.zoo.ufl.edu/bolker
Box 118525                                   (ph)  352-392-5697
Gainesville, FL 32611-8525                   (fax) 352-392-3704

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list