Re: [R] determining a parent function name

2007-05-31 Thread Vladimir Eremeev
Does tail(capture.output(traceback()),n=1) do what you want? that is error - function(...) { msg - paste(..., sep = ) if(!length(msg)) msg - if(require(tcltk, quiet = TRUE)) { tt - tktoplevel() tkwm.title(tt, Error) tkmsg - tktext(tt, bg = white)

Re: [R] determining a parent function name

2007-05-31 Thread Vladimir Eremeev
Vladimir Eremeev wrote: Does tail(capture.output(traceback()),n=1) do what you want? that is Hmmm... Seems, no... Having the earlier error() definition and bar-function() error(asdasdf) ft-function() bar() ft() I get in the tcl/tk window: Error in bar(): asdasdf bar() I

Re: [R] determining a parent function name

2007-05-31 Thread Sundar Dorai-Raj
Hi, Vladimir, In general, this won't work since traceback only contains the stack from the last uncaught error (see ?traceback). When traceback is called below it would be from the previous error, not the current one. error - function() { parent - tail(capture.output(traceback()), n = 1)

Re: [R] determining a parent function name

2007-05-31 Thread Sundar Dorai-Raj
Hi, Vladimir, Sorry, didn't see this reply. .Traceback - NULL doesn't work because of the warning in ?traceback. Warning: It is undocumented where '.Traceback' is stored nor that it is visible, and this is subject to change. Prior to R 2.4.0 it was stored in the workspace,

Re: [R] determining a parent function name

2007-05-31 Thread Martin Morgan
Hi sundar -- maybe myerr - function(err) err$call foo - function() stop() tryCatch({ foo() }, error=myerr) foo() suggests a way to catch errors without having to change existing code or re-invent stop? Martin Sundar Dorai-Raj [EMAIL PROTECTED] writes: Hi, Vladimir, Sorry, didn't see

Re: [R] determining a parent function name

2007-05-31 Thread Sundar Dorai-Raj
Thanks for the input. I don't think this will help either since it still requires you know the error occurred in foo. I settled on passing the call to error: error - function(..., call) {} foo - function() error(some error, call = match.call()) Thanks, --sundar Martin Morgan said the

Re: [R] determining a parent function name

2007-05-31 Thread Ismail Onur Filiz
Hi, On Wednesday 30 May 2007 14:53:28 Sundar Dorai-Raj wrote: error - function(...) {    msg - paste(..., sep = )    if(!length(msg)) msg -    if(require(tcltk, quiet = TRUE)) {      tt - tktoplevel()      tkwm.title(tt, Error)      tkmsg - tktext(tt, bg = white)      tkinsert(tkmsg,

Re: [R] determining a parent function name

2007-05-31 Thread Sundar Dorai-Raj
Thanks! That's the answer I was looking for. --sundar Ismail Onur Filiz said the following on 5/31/2007 12:23 PM: Hi, On Wednesday 30 May 2007 14:53:28 Sundar Dorai-Raj wrote: error - function(...) { msg - paste(..., sep = ) if(!length(msg)) msg - if(require(tcltk, quiet =

Re: [R] determining a parent function name

2007-05-31 Thread Ismail Onur Filiz
Sorry for replying to myself, but: On Thursday 31 May 2007 12:23:12 Ismail Onur Filiz wrote: Hi, On Wednesday 30 May 2007 14:53:28 Sundar Dorai-Raj wrote: error - function(...) {    msg - paste(..., sep = )    if(!length(msg)) msg -    if(require(tcltk, quiet = TRUE)) {      tt -

Re: [R] determining a parent function name

2007-05-31 Thread Sundar Dorai-Raj
Ismail Onur Filiz said the following on 5/31/2007 1:03 PM: Sorry for replying to myself, but: On Thursday 31 May 2007 12:23:12 Ismail Onur Filiz wrote: Hi, On Wednesday 30 May 2007 14:53:28 Sundar Dorai-Raj wrote: error - function(...) { msg - paste(..., sep = ) if(!length(msg))

[R] determining a parent function name

2007-05-30 Thread Sundar Dorai-Raj
Hi, All, I'm writing a wrapper for stop that produces a popup window using tcltk. Something like: error - function(...) { msg - paste(..., sep = ) if(!length(msg)) msg - if(require(tcltk, quiet = TRUE)) { tt - tktoplevel() tkwm.title(tt, Error) tkmsg - tktext(tt, bg =