[R-gregmisc-users] SF.net SVN: r-gregmisc: [1088] trunk/gtools
Brought to you by:
warnes
From: <wa...@us...> - 2007-04-12 21:17:00
|
Revision: 1088 http://svn.sourceforge.net/r-gregmisc/?rev=1088&view=rev Author: warnes Date: 2007-04-12 14:16:41 -0700 (Thu, 12 Apr 2007) Log Message: ----------- Add ask() function to prompt the user and collect a single response. Modified Paths: -------------- trunk/gtools/NAMESPACE trunk/gtools/NEWS Added Paths: ----------- trunk/gtools/R/ask.R trunk/gtools/man/ask.Rd Modified: trunk/gtools/NAMESPACE =================================================================== --- trunk/gtools/NAMESPACE 2007-04-07 13:41:51 UTC (rev 1087) +++ trunk/gtools/NAMESPACE 2007-04-12 21:16:41 UTC (rev 1088) @@ -2,6 +2,7 @@ export( addLast, + ask, assert, capture, combinations, Modified: trunk/gtools/NEWS =================================================================== --- trunk/gtools/NEWS 2007-04-07 13:41:51 UTC (rev 1087) +++ trunk/gtools/NEWS 2007-04-12 21:16:41 UTC (rev 1088) @@ -1,3 +1,9 @@ +SVN +---- + +- Add ask() function to prompt the user and collect a single response. + + gtools 2.3.0 ------------ Added: trunk/gtools/R/ask.R =================================================================== --- trunk/gtools/R/ask.R (rev 0) +++ trunk/gtools/R/ask.R 2007-04-12 21:16:41 UTC (rev 1088) @@ -0,0 +1,5 @@ +ask <- function(msg="Press <RETURN> to continue: ") + { + cat(msg); + readLines(con=stdin(),n=1) + } Added: trunk/gtools/man/ask.Rd =================================================================== --- trunk/gtools/man/ask.Rd (rev 0) +++ trunk/gtools/man/ask.Rd 2007-04-12 21:16:41 UTC (rev 1088) @@ -0,0 +1,36 @@ +\name{ask} +\alias{ask} +\title{Display a prompt and collect the user's response} +\description{ + Display a prompt and collect the user's response +} +\usage{ +ask(msg = "Press <RETURN> to continue: ") +} +\arguments{ + \item{msg}{Character vetor providing the message to be displayed} +} +\details{ + The prompt message will be displayed, and then \code{readLines} is + used to collect a single input value (possibly empty), which is then + returned. +} +\value{ + A character scalar containing the input providede by the user. +} +\author{Gregory R. Warnes \email{gr...@ra...}} +\seealso{ \code{\link{readLines}}, \code{\link{scan}} } +\examples{ + +# use default prompt +ask() + +silly <- function() +{ + age <- ask("How old aroe you? ") + age <- as.numeric(age) + cat("In 10 years you will be", age+10, "years old!\n") +} + +} +\keyword{IO} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |