Jump to content

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


muthu123

Recommended Posts

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.

Link to comment
Share on other sites

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" ")"))

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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]) 

Link to comment
Share on other sites

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)))

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...