A polyline-joining routine that works in BricsCad (which doesn't accept an M option for Pedit):
;; Join Into polyline - joins a set of contiguous lines, arcs, and/or polylines into a polyline.
;; Selection window can include inappropriate entities, which are ignored.
(defun c:JI ()
(princ "Join lines, arcs, polylines into a single polyline. ")
(sssetfirst nil nil)
(setq ent1 nil)
(while (= ent1 nil) (setq ent1 (entsel "Pick first entity: ")) )
(setq type1 (cdr (assoc 0 ent1) ))
(setq ss1 (ssget '((-4 . "<OR") (0 . "LINE") (0 . "ARC") (0 . "LWPOLYLINE") (-4 . "OR>"))))
(if (= type1 "LWPOLYLINE") (command "Pedit" ent1 "j" ss1 "" ))
(if (/= type1 "LWPOLYLINE") (command "Pedit" ent1 "y" "j" ss1 "" ""))
(sssetfirst nil (ssget "L"))
)