home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!mcsun!uknet!edcastle!chemeng.ed.ac.uk!stow!haitham
- From: haitham@Chemeng.Ed.Ac.Uk (Haitham Lababidi)
- Newsgroups: comp.lang.lisp
- Subject: Re: converting from strings to ___
- Message-ID: <1992Jul23.090403.23596@chemeng.ed.ac.uk>
- Date: 23 Jul 92 09:04:03 GMT
- References: <1992Jul22.194639.10131@cs.brown.edu>
- Sender: news@chemeng.ed.ac.uk
- Reply-To: haitham@Chemeng.Ed.Ac.Uk
- Organization: Edinburgh University Chemical Engineering Department.
- Lines: 36
- Originator: haitham@stow
-
- In article 10131@cs.brown.edu, map@cs.brown.edu (Mike Perkowitz) writes:
- >
- >i'm working on a system where i'm getting user input through Motif widgets
- >(using CLM). in one part, the user can specify values for certain parameters
- >through a text widget. the problem is that the value held by the text widget
- >will always be a string. i need to be able to treat that string as a number or
- >even as any arbitrary value (t/nil, for example). what it really seems like i
- >need to be able to do is just "remove the quotes" from the string and turn it
- >into a symbol or something. does anybody have any ideas? is this doable? to
- >what extent? any assistance would be greatly appreciated...
- >
- >thanks,
-
- Try the following function:
-
- (defun my-read-string (string)
- (let (val errorp error-string)
- (handler-case
- (setf val (read-from-string string nil :empty-string))
- (condition (error-condition)
- (setf error-string error-condition
- errorp :read-error val nil)))
- (when (eq val :empty-string) (setf val nil errorp :empty-string))
- (when (and errorp (eq errorp :read-error))
- (format t "Error: read-from-string:~%~%~A" error-string))
- (values val errorp error-string)))
-
- You can then easily direct the error (if any) to a "notice-prompt" originated from
- the widget you are reading from.
-
-
- +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- Dr. Haitham Lababidi Tel +44 31 650 4862
- Department of Chemical Engineering Email haitham@uk.ac.ed
- Edinburgh University
- +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-