+ Reply to Thread
Results 1 to 10 of 10
  1. #1
    Senior Member
    Using
    AutoCAD 2007
    Join Date
    Dec 2009
    Posts
    152

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

    Registered forum members do not see this ad.

    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.

  2. #2
    Junior Member
    Using
    AutoCAD 2010
    Join Date
    Jun 2010
    Location
    Pune, India
    Posts
    16

    Default

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

  3. #3
    Senior Member
    Using
    AutoCAD 2007
    Join Date
    Dec 2009
    Posts
    152

    Default

    Quote Originally Posted by SanganakSakha View Post
    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.

  4. #4
    Senior Member
    Discipline
    See details...
    gile's Discipline Details
    Discipline
    See details below.
    Details
    Programming
    Using
    AutoCAD 2017
    Join Date
    Jul 2009
    Location
    Marseille France
    Posts
    180

    Default

    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

  5. #5
    Junior Member
    Using
    AutoCAD 2010
    Join Date
    Jun 2010
    Location
    Pune, India
    Posts
    16

    Default

    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.

  6. #6
    Senior Member
    Computer Details
    VVA's Computer Details
    Operating System:
    Windows 7
    CPU:
    Intel Core i5-2400
    RAM:
    8 Gb
    Graphics:
    Nvidia Quadro 600
    Primary Storage:
    Seagate 500 GB + WD 750 GB
    Monitor:
    Philips 27"
    Using
    AutoCAD 2013
    Join Date
    Dec 2006
    Location
    Minsk, Belarus
    Posts
    447

    Default

    could be so satisfied?
    Code:
    (read (strcat "(" "\"" "1.5X250X600" "\"" ")")) ;_return ("1.5X250X600")

  7. #7
    Quantum Mechanic BIGAL's Avatar
    Using
    Civil 3D 2016
    Join Date
    Dec 2005
    Location
    GEELONG AUSTRALIA
    Posts
    10,709

    Default

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

  8. #8
    Quantum Mechanic Lee Mac's Avatar
    Computer Details
    Lee Mac's Computer Details
    Operating System:
    Win 7 Pro / Win 10 Pro / Linux Mint
    Discipline
    Multi-disciplinary
    Lee Mac's Discipline Details
    Discipline
    Multi-disciplinary
    Details
    Custom Programming / Software Customisation
    Using
    AutoCAD 2018
    Join Date
    Aug 2008
    Location
    London, England
    Posts
    19,593

    Default

    Quote Originally Posted by BIGAL View Post
    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
    Lee Mac ProgrammingTwitterExchange App StoreDropbox (500MB free)

    With Mathematics there is the possibility of perfect rigour, so why settle for less?

  9. #9
    Senior Member
    Using
    AutoCAD 2010
    Join Date
    Jul 2010
    Posts
    370

    Default

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

    Regards

    Michaels

  10. #10
    Quantum Mechanic Lee Mac's Avatar
    Computer Details
    Lee Mac's Computer Details
    Operating System:
    Win 7 Pro / Win 10 Pro / Linux Mint
    Discipline
    Multi-disciplinary
    Lee Mac's Discipline Details
    Discipline
    Multi-disciplinary
    Details
    Custom Programming / Software Customisation
    Using
    AutoCAD 2018
    Join Date
    Aug 2008
    Location
    London, England
    Posts
    19,593

    Default

    Registered forum members do not see this ad.

    Quote Originally Posted by Michaels View Post
    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:

    Code:
    "(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.
    Lee Mac ProgrammingTwitterExchange App StoreDropbox (500MB free)

    With Mathematics there is the possibility of perfect rigour, so why settle for less?

Similar Threads

  1. "save" in the file "pull down menu" not working
    By kfarrar in forum Civil 3D & LDD
    Replies: 11
    Last Post: 25th Dec 2013, 10:22 am
  2. (read (strcat "(" "TUBE150X150X4.5 20.2" ")"))
    By muthu123 in forum AutoLISP, Visual LISP & DCL
    Replies: 11
    Last Post: 21st Jun 2010, 03:40 am
  3. Replies: 1
    Last Post: 25th Nov 2009, 06:35 pm
  4. AcadMap3D 2010_freezes on "open" or "save" ...
    By Jest in forum AutoCAD Bugs, Error Messages & Quirks
    Replies: 8
    Last Post: 26th Aug 2009, 08:27 am
  5. "Union" Meshes or "Slice" 3D Mesh
    By Peter31712 in forum AutoCAD 3D Modelling & Rendering
    Replies: 1
    Last Post: 29th Apr 2004, 11:11 pm

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts