Philippe Grosjean wrote:
Hello,

I need a similar behaviour as with the prompt: asking to complete incomplete
R command with eval(parse(text = ....))
Is it a way to make the difference between an illegal and an incomplete R
command in a string?
For instance:


parse(text="ls()")

expression(ls())

This is fine!


parse(text="ls(")

Error in parse(file, n, text, prompt) : parse error

This is an incomplete command, and I want to ask to the user for further
input (multiline command)

Hello Phillipe,

why not using something like this:

> ok<-try(parse(text="ls("), silent=TRUE)
> ok
[1] "Error in parse(file, n, text, prompt) : parse error\n"
attr(,"class")
[1] "try-error"

and then check if "ok" is an expression:

> is.expression(ok)
FALSE


Thomas P.

______________________________________________
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

Reply via email to