Search code examples
autolisp

How to print values in Autolisp?


I'm writing my simple script in AutoCAD to select a table and to retrieve some data of the table with printing it in console.

(defun C:test (/)
    (vl-load-com) 
    (setvar "CTAB" "Model")
(princ "\n*** Pick a table ***")
  (if (setq ss (ssget "_:S:E:L" '((0 . "ACAD_TABLE"))))
      (setq table (vlax-ename->vla-object (ssname ss 0)))
    )       
        
(setq  table_rows (vla-get-rows table)
       table_width (vla-get-width table)
 )  
    
(prinс (strcat "Num of rows is" table_rows ", table width is " table_width))
)

After running this script and picking a table of 57 rows in Autocad it returns me a mistake:

wrong type of argument: stringp 57

How could I fix it?


Solution

  • strcat needs string arguments. In Your case table_rows is integer and table_width looks like real. So You need to convert by itoa and rtos

    Try this:

    (prinс (strcat "Num of rows is" (itoa table_rows) ", table width is " (rtos table_width)))