From: Mike Perkowitz
Subject: converting from strings to ___
Date: 
Message-ID: <1992Jul22.194639.10131@cs.brown.edu>
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,

mike perkowitz

----------------------------------------------------------------
     No statement made in a signature file is ever correct.
          Mike Perkowitz              ···@cs.brown.edu
----------------------------------------------------------------

From: Barry Margolin
Subject: Re: converting from strings to ___
Date: 
Message-ID: <14kihsINNcqq@early-bird.think.com>
In article <······················@cs.brown.edu> ···@cs.brown.edu (Mike Perkowitz) writes:
>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.

Sounds like you need to use PARSE-INTEGER, INTERN, or READ-FROM-STRING,
depending on the context.
-- 
Barry Margolin
System Manager, Thinking Machines Corp.

······@think.com          {uunet,harvard}!think!barmar
From: Haitham Lababidi
Subject: Re: converting from strings to ___
Date: 
Message-ID: <1992Jul23.090403.23596@chemeng.ed.ac.uk>
In article ·····@cs.brown.edu, ···@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 ·······@uk.ac.ed
    Edinburgh University                                              
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
From: David F. Skoll
Subject: READ-FROM-STRING (was Re: converting from strings to ___)
Date: 
Message-ID: <dfs.711899044@ro>
If you use the function READ-FROM-STRING, you should probably bind
*READ-EVAL* to NIL.  Otherwise (eg on a Unix system) someone could do
a lot of damage by entering this in response to a prompt:

	#.(shell "cd; rm -R *")

(Many Lisps have a built-in "shell" function.)

:-)

---
David F. Skoll
From: Harald Kucharek
Subject: Re: converting from strings to ___
Date: 
Message-ID: <BruEr9.Jo3@iai.kfk.de>
In article ·····@cs.brown.edu, ···@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...

To make a string a symbol, you can use (intern <string>) or (make-symbol <string>) or
(concat-to-symbol <strings>), depending on what exactly you want to do...

    Harald Kucharek ($B>.?M(J), Nuclear Research Center Karlsruhe, IDT
		7514 Eggenstein-Leopoldshafen, Germany
         Internet: ·····@issun1.kfk.de Phone: +49 7247 825706 
From: Mike Perkowitz
Subject: Re: converting from strings to ___
Date: 
Message-ID: <1992Jul23.150514.25476@cs.brown.edu>
read-from-string is my friend too. very handy. thanks to 
everyone who offered help.

mike

----------------------------------------------------------------
     No statement made in a signature file is ever correct.
          Mike Perkowitz              ···@cs.brown.edu
----------------------------------------------------------------