Author Topic: Is it possible to open lsp file?  (Read 4222 times)

0 Members and 1 Guest are viewing this topic.

Adesu

  • Guest
Is it possible to open lsp file?
« 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)
  )                               
« Last Edit: March 09, 2007, 04:02:30 AM by Adesu »

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Is it possible to open lsp file?
« Reply #1 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))
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Is it possible to open lsp file?
« Reply #2 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.
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Is it possible to open lsp file?
« Reply #3 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.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Is it possible to open lsp file?
« Reply #4 on: March 09, 2007, 08:10:53 PM »
I don't know a way to do this.
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

Adesu

  • Guest
Re: Is it possible to open lsp file?
« Reply #5 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)
  )                           

fools

  • Newt
  • Posts: 72
  • China
Re: Is it possible to open lsp file?
« Reply #6 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

<Edit by CAB: Removed Copyrighted Material and replaced with link>
« Last Edit: March 10, 2007, 09:50:28 AM by CAB »
Good good study , day day up . Sorry about my Chinglish .

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Is it possible to open lsp file?
« Reply #7 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. :-)   
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

FengK

  • Guest
Re: Is it possible to open lsp file?
« Reply #8 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

DanB

  • Bull Frog
  • Posts: 367
Re: Is it possible to open lsp file?
« Reply #9 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

Adesu

  • Guest
Re: Is it possible to open lsp file?
« Reply #10 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

DanB

  • Bull Frog
  • Posts: 367
Re: Is it possible to open lsp file?
« Reply #11 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>