had a typo of blkl instead of blk so nothing was found when searching the block table since blkl wasn't a defined variable. As for displaying the list AutoLISP always prints the value of the last evaluated expression to the command line when exiting the function. in some cases you want this when your using it to return a list or some other value. when you don't want this to happen you just use a (princ) so nothing is outputted
(defun c:Foo1 ()
(princ "Hello, World!") ;will display as "Hello, World!
(princ)
)
(defun c:Foo2 ()
(princ "Hello, World!") ;will display as "Hello, World!Hello, World!"
)
to get what you want you are going to have to combine Steven's and my code
(defun c:foo ()
(setq myblks '("BlockA" "BlockB" "BlockC"))
(foreach blk myblks
(if (tblsearch "BLOCK" blk)
(cond
((eq blk "BlockA")
(command "-insert" "Block1" "0,0" "" "" "")
)
((eq blk "BlockB")
(command "-insert" "Block2" "0,0" "" "" "")
)
((eq blk "BlockC")
(command "-insert" "Block3" "0,0" "" "" "")
)
)
)
)
(princ)
)