Hello all, I've got a quick question about the checking of formulas. I mistakenly typed "//" instead of "/" into several 'def' commands in my model. Unfortunately it took me a long time to find the mistake, since it was a complex model and by some fluke the equation gave almost (but not quite) the expected value. Since "//" doesn't seem to be a valid Ifeffit operator, why didn't either Ifeffit or Artemis pick it up? Regards, Peter Peter Southon Postdoctoral Fellow School of Chemistry University of Sydney NSW 2006, Australia +61 2 9351 7482
On Monday 15 November 2004 1:56 am, Peter Southon wrote:
Hello all,
I've got a quick question about the checking of formulas. I mistakenly typed "//" instead of "/" into several 'def' commands in my model. Unfortunately it took me a long time to find the mistake, since it was a complex model and by some fluke the equation gave almost (but not quite) the expected value. Since "//" doesn't seem to be a valid Ifeffit operator, why didn't either Ifeffit or Artemis pick it up?
I can't speak for Ifeffit, but Artemis is only as smart as I am -- and that's not very smart! A check for the string "//" is easy enough. I'll put it on the todo list. Any other little typos that you can think of that Artemis should be aware of? B -- Bruce Ravel ----------------------------------- ravel@phys.washington.edu Code 6134, Building 3, Room 405 Naval Research Laboratory phone: (1) 202 767 2268 Washington DC 20375, USA fax: (1) 202 767 4642 NRL Synchrotron Radiation Consortium (NRL-SRC) Beamlines X11a, X11b, X23b National Synchrotron Light Source Brookhaven National Laboratory, Upton, NY 11973 My homepage: http://feff.phys.washington.edu/~ravel EXAFS software: http://feff.phys.washington.edu/~ravel/software/exafs/
Hi Bruce, Peter, Ifeffit does print a warning message about a syntax error on using '//'. But it's completely believable and forgivable that Artemis doesn't catch this. Bruce, would it help if a flag was set indicating 'syntax error' in addition to printing the warning message? That way you could wrap each of the definitions with a perl function that did the ifeffit command and check for syntax errors, doing something sensible (popping up a warning dialog box, for example) on a syntax error. That might be better than checking for '//' itself, because it would detect other syntax errors as well. A flag meaning 'math error' (as on divide-by-zero or sqrt(-1)) might be useful too, I suppose.... --Matt
Bruce, would it help if a flag was set indicating 'syntax error' in addition to printing the warning message?
Yes, very much so.
That way you could wrap each of the definitions with a perl function that did the ifeffit command and check for syntax errors, doing something sensible (popping up a warning dialog box, for example) on a syntax error.
Exactly. That would be really helpful and a great service to the user.
A flag meaning 'math error' (as on divide-by-zero or sqrt(-1)) might be useful too, I suppose....
Yes indeed. B
Hi Bruce, Here's a proposed change for checking for syntax and other errors. (This would make v. 1.2.7. I might be willing to toss in a few more things too). First, and mostly, add '&status' variable to hold status flags from commands. The values of &status could be (open for suggestion): 0.0 no error (see below) 1.0 benign warnings (eg, 'unknown keyword' for commands) 2.0 more serious warnings: syntax errors, evaluation errors (divide-by-zero), or a command stopped prematurely for some other reason (eg, "can't find an array for energy"). 3.0 severe warnings: hitting an internal program limit, 'file not found', and so on. Those could be changed or expanded, to say, be along the lines of: 1.1 'unknown keyword' 1.2 'data out of order for spline/pre_edge....' 1.3 fit couldn't determine error bars.... 2.0 syntax error during parsing 2.1 evaluation error (eg, divide-by-zero) 2.2 can't find enough arrays to process command and so on. That's mostly a matter of how detailed of the value should be as opposed to parsing the strings that would be in the echo buffer. I'd imagine that more &status values would be better than parsing the messages. I would also propose that &status is _not_ automatically set to 0 prior to each command. This would mean that the user / script writer would have to explicilty set &status = 0 as a way to 'clear warning messages'. That would lead to a wrapper around ifeffit that does this (ignoring the saving,logging of the command): wrap_ifeffit(command_string) { set &status to 0 execute command_string check &status react to &status (maybe look at echo buffer at this point) } on the whole, that first 'set &status to 0' doesn't seem so bad. The important reason to _not_ automatically reset &status is so that warnings stick even when multiple commands and macros are run. So, the main questions to you, Sam, and anyone else who's interested in writing extended scripts / programs are: Is this an OK approah? How fine-grained should the values of &status be? --Matt
participants (4)
-
Bruce Ravel
-
Bruce Ravel
-
Matt Newville
-
Peter Southon