Thank you Thomas for your answer. This is of course what I intend to do
(indeed, to use a tryCatch(), instead of I try(). However, I would like to
have a different behaviour depending if the synthax is incorrect "ls())" for
instance, or incomplete "ls(" for instance. Indeed, exactly like the
distinction made at the command line:> ls()) # This generates an error Error: syntax error > ls( # This is not an error, but a multiline command + If you use parse() within a try(), you got the same error message in both cases: "Error in parse(file, n, text, prompt) : parse error". So, it is not possible to discriminate between the two situation in this context. Is it a way to cope with that? Best, Philippe Grosjean > -----Original Message----- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On Behalf Of Thomas Petzoldt > Sent: Thursday, December 16, 2004 3:18 PM > To: [EMAIL PROTECTED] > Cc: [EMAIL PROTECTED] > Subject: Re: [R] Detecting incomplete commands > > 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 > > ______________________________________________ [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
