TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: Adesu on March 09, 2007, 03:58:16 AM

Title: Is it possible to open lsp file?
Post by: Adesu on March 09, 2007, 03:58:16 AM
Hi Alls,
I have plan to open a lsp file,with autolisp program,but I still confuse how to open a lsp file without touch of visual lisp editor.
Code: [Select]
(defun c:test (/ dcl_id file_folder all_file_name name lst ans sf nf xf ?f file)
  (setq dcl_id (load_dialog "Display File Name.dcl"))
  (if
    (not (new_dialog "dfn" dcl_id))
    (exit)
    )                                                                   ; if
  (vl-load-com)
  (setq file_folder "D:/YBI/Program/AutoLisp/Lisp program/My Alls Program")
  (setq all_file_name (cddr (vl-directory-files file_folder)))
  (setq all_file_name
(mapcar '(lambda (x)(nth x all_file_name))
(vl-sort-i all_file_name '<)))
  (foreach file_name all_file_name                                       
    (setq name (cons (substr file_name 6 50) name))
    )                                                                       ; foreach
  (setq lst (acad_strlsort (reverse name)))
  (start_list "lb")
  (mapcar 'add_list lst)    
  (end_list)
  (mode_tile "lb" 2)
  (action_tile
    "lb"
    "(setq data_name (nth (atoi $value) lst)) ")
  (action_tile "accept" "(done_dialog 1)")
  (action_tile "cancel" "(done_dialog 0)")
  (setq ans (start_dialog))
  (unload_dialog dcl_id)
  (if
    (= ans 1)
    (progn
      (setq sf data_name)
      (foreach x all_file_name
(setq nf x)
(setq xf (vl-string-right-trim sf nf))
(setq ?f (vl-string-left-trim xf nf))
(if
  (= ?f sf)
  (setq file nf)
  )                                               ; if
)                                                 ; foreach
      ;(alert (strcat "\nThe file you seacrh is = " file))
      ; from here I want open lsp file in vlide editor,data base on variable
      ; "file", I mean for more clear look at attach file,it choose "Edit Color.lsp",
      ; now in session visual lisp editor, "Edit Color.lsp" file should open.
      )                                                   ; progn
    (alert "\nNot yet selected list,please try again")
    )                                                     ; if
  (princ)
  )                               
Title: Re: Is it possible to open lsp file?
Post by: T.Willey on March 09, 2007, 12:11:43 PM
I didn't look at the code, but is this what you are looking for?  This will open the selected lisp file in notepad.
Code: [Select]
(startapp "notepad.exe" (getfiled "" "" "lsp" 4))
Title: Re: Is it possible to open lsp file?
Post by: CAB on March 09, 2007, 01:08:27 PM
Tim, I think he wants to fire up VLIDE & auto load a specific lisp file for editing.

I don't think VLIDE or VLISP will take an argument.
Title: Re: Is it possible to open lsp file?
Post by: T.Willey on March 09, 2007, 01:26:54 PM
Oh.... Okay....

Thanks Alan.  I use notepad to write my lisp routines.  I know absolutely nothing about VLIDE.
Title: Re: Is it possible to open lsp file?
Post by: Kerry on March 09, 2007, 08:10:53 PM
I don't know a way to do this.
Title: Re: Is it possible to open lsp file?
Post by: Adesu on March 09, 2007, 08:29:02 PM
I didn't look at the code, but is this what you are looking for?  This will open the selected lisp file in notepad.
Code: [Select]
(startapp "notepad.exe" (getfiled "" "" "lsp" 4))

Hi Willey,
I looking for a file it's name "Edit Color" (look at attach file),then visual lisp editor should open by lisp program,and at the glace that file open too, the user without click open icon in visual lisp editor.

Code: [Select]
(defun c:test (/ dcl_id file_folder all_file_name name lst ans sf nf xf ?f file)
  (setq dcl_id (load_dialog "Display File Name.dcl"))
  (if
    (not (new_dialog "dfn" dcl_id))
    (exit)
    )                                                                   ; if
  (vl-load-com)
  (setq file_folder "D:/YBI/Program/AutoLisp/Lisp program/My Alls Program")
  (setq all_file_name (cddr (vl-directory-files file_folder)))
  (setq all_file_name
(mapcar '(lambda (x)(nth x all_file_name))
(vl-sort-i all_file_name '<)))
  (foreach file_name all_file_name                                       
    (setq name (cons (substr file_name 6 50) name))
    )                                                                       ; foreach
  (setq lst (acad_strlsort (reverse name)))
  (start_list "lb")
  (mapcar 'add_list lst)    
  (end_list)
  (mode_tile "lb" 2)
  (action_tile
    "lb"
    "(setq data_name (nth (atoi $value) lst)) ")
  (action_tile "accept" "(done_dialog 1)")
  (action_tile "cancel" "(done_dialog 0)")
  (setq ans (start_dialog))
  (unload_dialog dcl_id)
  (if
    (= ans 1)
    (progn
      (setq sf data_name)
      (foreach x all_file_name
(setq nf x)
(setq xf (vl-string-right-trim sf nf))
(setq ?f (vl-string-left-trim xf nf))
(if
  (= ?f sf)
  (setq file nf)
  )                                               ; if
)                                                 ; foreach
      (startapp "Visual Lisp Editor" file)
      ; "notepad.exe" should replace by Visual lisp editor
      )                                                   ; progn
    (alert "\nNot yet selected list,please try again")
    )                                                     ; if
  (princ)
  )                           
Title: Re: Is it possible to open lsp file?
Post by: fools on March 10, 2007, 05:07:15 AM
Hi  Adesu , you can write the filename you want to open into Vlide.dsk like this code

edlisp.lsp (http://paracadd.com/lisp/edlisp.lsp)

<Edit by CAB: Removed Copyrighted Material and replaced with link>
Title: Re: Is it possible to open lsp file?
Post by: Kerry on March 10, 2007, 08:15:09 AM
Interesting solution by Henry Francis,

It will require some modification to work in AutoCAD versions after 2002.
... I don't think I'd use it myself, and I wouldn't provide it for clients to use .. that's just me though. :-)   
Title: Re: Is it possible to open lsp file?
Post by: FengK on March 10, 2007, 08:48:50 PM

Hi Willey,
I looking for a file it's name "Edit Color" (look at attach file),then visual lisp editor should open by lisp program,and at the glace that file open too, the user without click open icon in visual lisp editor.


if you don't mind using third-party tools, i think it can be done with AutoItX without difficulty. AutoIt is free and you can find more info. about it at http://www.autoitscript.com/autoit3/index.php
Title: Re: Is it possible to open lsp file?
Post by: DanB on May 07, 2007, 10:11:42 AM
Adesu: Would you being willing/able to share the "Display File Name.dcl" you have?

Or can anyone assist with populating a list in a DCL to show certain file types in a folder (i.e. just *.lsp).  I presume this is similar to the getfiled function but I do not know how to get this going.  I am very new to writing DCL (read, never done this before) so I am trying out my first dcl code and I wanted to try something with loading my own lisp routines.

Any nudge in the right direction would be appreciated.

Thanks,
Dan
Title: Re: Is it possible to open lsp file?
Post by: Adesu on May 07, 2007, 07:28:19 PM
Hi DanB,
here my dcl code
Code: [Select]
// dfn is to display file name
dfn : dialog {label = "DISPLAY FILE NAME";
    : paragraph {key = "titles";
    : concatenation {
    : text_part {label = "Select a file name";}   
    }
    }
    : list_box {key = "lb";               
               fixed_width = true;
               width = 50;
               height = 25;}
    ok_cancel;}

Adesu: Would you being willing/able to share the "Display File Name.dcl" you have?

Or can anyone assist with populating a list in a DCL to show certain file types in a folder (i.e. just *.lsp).  I presume this is similar to the getfiled function but I do not know how to get this going.  I am very new to writing DCL (read, never done this before) so I am trying out my first dcl code and I wanted to try something with loading my own lisp routines.

Any nudge in the right direction would be appreciated.

Thanks,
Dan
Title: Re: Is it possible to open lsp file?
Post by: DanB on May 08, 2007, 09:15:49 AM
Thanks, I did find some more information yesterday afternoon on creating a list box. I came close to figuring out what I needed but still have some learning to do. Having something to compare to helps me alot when going through this. Hopefully I will have some time today to get back into it.

Thanks again,
Dan

<edit typos>