X
PrevPrev Go to previous topic
NextNext Go to next topic
Last Post 12 Apr 2012 08:17 AM by  anon
procedure without parameters
 2 Replies
Sort:
You are not authorized to post a reply.
Author Messages

anon



New Member


Posts:
New Member


--
12 Apr 2012 08:17 AM
    I have written a procedure "toto" that has no arguments, but 4 keywords. My problem is if I call the procedure with one or more arguments it tells me: "TOTO: Incorrect number of arguments." Instead I would like an error message telling me what is the usage of the procedure, something like: "toto, car=car, bus=bus, train=train, boat=boat" So I added at the beginning of my procedure the following: IF N_PARAMS() NE 0 THEN PRINT, "toto, car=car, bus=bus, train=train, boat=boat" However, because I called the procedure with too many arguments, IDL never enters inside the procedure, and always returns with the insignificant error message: "TOTO: Incorrect number of arguments." Does anyone knows how to avoid this error message and print something else when we call a procedure with too many arguments ? Many thanks in advance EA

    Deleted User



    New Member


    Posts:
    New Member


    --
    13 Apr 2012 06:59 AM
    Unfortunately, you can't trap this error because it is intercepted by IDL before the call even makes it to your program. One of the things IDL does when a program is compiled is make a list of the number of arguments and the names of the keywords involved. When a program is called, IDL consults this list. If you have used two many arguments, or a keyword that's not on the list, the error is flagged and dealt with *before* your program is called. The best you can do in this situation is train your users to read the (extremely well-written!) program documentation. Good luck wit that!

    Deleted User



    New Member


    Posts:
    New Member


    --
    13 Apr 2012 07:04 AM
    I apologize for the spelling and grammar in my last post ("two" instead of "too"). Sometimes when I get up late after a long day of trail maintenance, like this morning, Coyote gets impatient and starts answering the mail on his own. I've reprimanded him yet again. :-(
    You are not authorized to post a reply.