From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Cecil Westerhof Newsgroups: gmane.emacs.help Subject: Checking parameters Date: Sun, 17 Jun 2007 12:17:08 +0200 Message-ID: <46750a24$0$338$e4fe514c@news.xs4all.nl> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7Bit X-Trace: sea.gmane.org 1182076887 5150 80.91.229.12 (17 Jun 2007 10:41:27 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Sun, 17 Jun 2007 10:41:27 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sun Jun 17 12:41:25 2007 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1HzsC7-0001xB-Ep for geh-help-gnu-emacs@m.gmane.org; Sun, 17 Jun 2007 12:41:19 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1HzsC6-0004PK-7u for geh-help-gnu-emacs@m.gmane.org; Sun, 17 Jun 2007 06:41:18 -0400 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!news.tele.dk!news.tele.dk!small.news.tele.dk!newsgate.cistron.nl!feeder.rekka.net!transit.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Original-Newsgroups: gnu.emacs.help User-Agent: KNode/0.8.0 Original-Lines: 27 Original-NNTP-Posting-Host: 213.84.157.201 Original-X-Trace: 1182075428 news.xs4all.nl 338 [::ffff:213.84.157.201]:10016 Original-X-Complaints-To: abuse@xs4all.nl Original-Xref: shelby.stanford.edu gnu.emacs.help:149539 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:45128 Archived-At: I am new to Emacs and lisp. What is the best way to check parameters and do error handling when they are not correct? I have the following function: (defun getHours(time) (interactive "sHH:MM: ") (let ((timelist (split-string time ":"))) (+ (string-to-number (car timelist)) (/ (string-to-number (cadr timelist)) 60.0 ) ) ) ) How do I check that there is exactly one parameter? And how do I check the format and give an error that works in interactive and normal mode? For example when I give (getHours "0:120") I get 2.0 How should I generate an error/exception?