muthu123 Posted July 8, 2010 Posted July 8, 2010 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. Quote
SanganakSakha Posted July 8, 2010 Posted July 8, 2010 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" ")")) Quote
muthu123 Posted July 8, 2010 Author Posted July 8, 2010 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. Quote
gile Posted July 8, 2010 Posted July 8, 2010 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 Quote
SanganakSakha Posted July 8, 2010 Posted July 8, 2010 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. Quote
VVA Posted July 8, 2010 Posted July 8, 2010 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]) Quote
BIGAL Posted July 10, 2010 Posted July 10, 2010 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))) Quote
Lee Mac Posted July 10, 2010 Posted July 10, 2010 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 Quote
Michaels Posted July 10, 2010 Posted July 10, 2010 I think it is better to use external file .txt and call them by openfile "r" finction Regards Michaels Quote
Lee Mac Posted July 10, 2010 Posted July 10, 2010 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. Quote
Recommended Posts
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.