Jump to content
muthu123

(read (strcat "(" "1.5X250X600" ")"))

Recommended Posts

muthu123

When we use this fucction

(read (strcat "(" "1.5X250X600" ")"))

 

it will return

(1).

 

But i need like this

(1.5X250X600)

 

Please help and thanks to Mr.Lee.

 

Yours,

Muthu.

Share this post


Link to post
Share on other sites
SanganakSakha

From help:

 

The read function parses the string representation of any LISP data and returns the first expression in the string, converting it to a corresponding data type.

 

 

Why not simply use (strcat "(" "1.5X250X600" ")")?

 

Or if you want to display the value at command prompt without quotes:

(princ (strcat "(" "1.5X250X600" ")"))

Share this post


Link to post
Share on other sites
muthu123
From help:

 

The read function parses the string representation of any LISP data and returns the first expression in the string, converting it to a corresponding data type.

 

 

Why not simply use (strcat "(" "1.5X250X600" ")")?

 

Or if you want to display the value at command prompt without quotes:

(princ (strcat "(" "1.5X250X600" ")"))

 

 

Actually My task is to return as a list.

Share this post


Link to post
Share on other sites
gile

Hi,

 

You can't get something like this : (1.5X250X600) because 1.5X250X600 is not a valid symbol name.

Even '(1.5X250X600) should return (1)

 

This is due to the fact 1.5X250X600 contains a period (.).

Have a look at the Developer's Help > AutoLISP Developer's Guide W> Using the AutoLISP Language > AutoLISP Basics > AutoLISP Data Type > Symbols and Variables

Share this post


Link to post
Share on other sites
SanganakSakha

Yes, Gile is right.

 

If acceptable, you could use , as a decimal separator instead of . and then have something like this:

 

(list '1,5X250X600)

 

It all depends on how you want to use this value - the larger picture.

Share this post


Link to post
Share on other sites
VVA

could be so satisfied?

(read (strcat "(" [b][color="Red"]"\""[/color][/b] "1.5X250X600" [b][color="Red"]"\""[/color] [/b]")")) ;_return ([color="Red"]"[/color]1.5X250X600[color="Red"]"[/color]) 

Share this post


Link to post
Share on other sites
BIGAL

I think this was answered in another post the problem is the ( ) the lisp sees these as part of the program not text. The simple way around is to use the "chr(x)" replace x with the keyboard character number from memory a=65 look up "ascii" function in lisp help,you only need like a 1 line lisp it gives the keyboard number.

 

(read (strcat chr(65) "1.5X250X600" chr(65)))

Share this post


Link to post
Share on other sites
Lee Mac
I think this was answered in another post the problem is the ( ) the lisp sees these as part of the program not text. The simple way around is to use the "chr(x)" replace x with the keyboard character number from memory a=65 look up "ascii" function in lisp help,you only need like a 1 line lisp it gives the keyboard number.

 

(read (strcat chr(65) "1.5X250X600" chr(65)))

 

The parenthesis make no difference - you can read these characters to interpret strings into valid LISP expressions.

 

The problem is as Gile describes in post #4

Share this post


Link to post
Share on other sites
Michaels

I think it is better to use external file .txt and call them by openfile "r" finction

 

Regards

 

Michaels

Share this post


Link to post
Share on other sites
Lee Mac
I think it is better to use external file .txt and call them by openfile "r" finction

 

Regards

 

Michaels

 

This again would make no difference as read-line would return:

 

"(1.5X250X600)"

 

Which, when evaluated by 'read' would result in (1) as 1.5X250X600 is being interpreted as an integer as it is not a valid symbol name.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×