strcat problem

Discussion in 'AutoCAD' started by spencer1971, Sep 27, 2004.

  1. spencer1971

    spencer1971 Guest

    I have this lsp that I have written to set dimstyl ltscale etc from a picked piece of text.

    I am getting an error when i run it saying

    Error: bad argument type: stringp 25

    I know it is to do with the two lines at the bottom

    (setq dst (strcat ds1 "-DIM"))
    (command "-dimstyle" "R" dst)

    the variable dst should be a string thus: 25-DIM or 50-DIM etc.

    Help



    (defun c:setsc (/ d h ds1 dst ds1)
    (setq e (entsel "\nSelect Text: ")
    d (entget (car e))
    h (cdr (assoc 40 d))
    )
    (if (= h 2.5) (setq ds1 1))
    (if (= h 5) (setq ds1 2))
    (if (= h 12.5) (setq ds1 5))
    (if (= h 25) (setq ds1 10))
    (if (= h 50) (setq ds1 20))
    (if (= h 62.5) (setq ds1 25))
    (if (= h 125) (setq ds1 50))
    (if (= h 250) (setq ds1 100))
    (if (= h 500) (setq ds1 200))
    (setvar "ltscale" ds1)
    (setvar "dimscale" ds1)
    (setq dst (strcat ds1 "-DIM"))
    (command "-dimstyle" "R" dst)
    )


    spencer
     
    spencer1971, Sep 27, 2004
    #1
  2. spencer1971

    Jürg Menzi Guest

    Hi spencer

    The solution:
    (setq dst (strcat (itoa ds1) "-DIM"))
    Because you can't merge an integer with a string without type conversion.

    Cheers
     
    Jürg Menzi, Sep 27, 2004
    #2
  3. spencer1971

    spencer1971 Guest

    Juerg

    Many thanks, That works perfectly

    Spencer
     
    spencer1971, Sep 27, 2004
    #3
  4. spencer1971

    Jürg Menzi Guest

    Welcome...¦-)

    Cheers
     
    Jürg Menzi, Sep 27, 2004
    #4
  5. spencer1971

    Adesu Guest

    Hi Jürg Menzi , like this

    _$ (setq ds1 234)
    234

    _$ (setq dst (strcat (itoa ds1) "-DIM"))
    "234-DIM"
    _$
     
    Adesu, Sep 28, 2004
    #5
  6. spencer1971

    Jürg Menzi Guest

    Hi Adesu

    Yes...

    Cheers
     
    Jürg Menzi, Sep 28, 2004
    #6
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.