Open lisp and search for string

Open lisp and search for string

vishshreevT578L
Advocate Advocate
4,349 Views
29 Replies
Message 1 of 30

Open lisp and search for string

vishshreevT578L
Advocate
Advocate

Hi.....

 

I am looking for source code which will open lisp file and search for prompted string and output will be files name.

 

For example.....

 

(DEFUN GETINFO ()
  (SUPERMAN (IF SPIDERMAN T NIL))
)

 

My superman function is somewhere in the folder which contains multiple lisps and I want to look for the same function to load it.

 

 

Thanks in advance.

Shreev
0 Likes
Accepted solutions (2)
4,350 Views
29 Replies
Replies (29)
Message 21 of 30

vishshreevT578L
Advocate
Advocate

Thank you so much sir......for your solution.

Shreev
0 Likes
Message 22 of 30

vishshreevT578L
Advocate
Advocate

Hi.....

 

Everything here works perfect but I don't want to draw a line in this case I just want to know in which file the string is stored in.....

 

can you please suggest on this.....

 

Thanks

Shreev
0 Likes
Message 23 of 30

pbejse
Mentor
Mentor

You are welcome vishshreevT578L Glad you find  code snippet useful.

 

Cheers

 

0 Likes
Message 24 of 30

pbejse
Mentor
Mentor

@vishshreevT578L wrote:

 

....I just want to know in which file the string is stored in.....


Not sure what you mean by that vishshreevT578L . Please elaborate.

0 Likes
Message 25 of 30

vishshreevT578L
Advocate
Advocate

I mean after the string is found in the particular file it should just print / princ location of that file

 

for example.

 

suppose my search word "defun a" is found at file "a.lsp" then it should notify me about in which file it is located.

 

That's it

Shreev
0 Likes
Message 26 of 30

pbejse
Mentor
Mentor

@vishshreevT578L wrote:

I mean after the string is found in the particular file it should just print / princ location of that file...


No worries, BUT that's exactly what phanaem code at post#5  is all about. well except the prompt of what to search for. Better yet, give the post a kudo or accept as solution , that post is as much part of this solution as any.

 

but anyhow

 

(defun c:Whereismylspcommand ( / opt theprogram)
  (vl-load-com)
      (initget "a b c")
      	(setq opt (getkword "\nwhat are you looking for [a/b/c]?: "))
      	(and      (setq theprogram (search_lsp (strcat "(defun " opt "*") "C:\\Users\\GAW81683\\Desktop\\shreev\\"))
		  ;; (or (eq (type (eval (read opt))) 'USUBR) (load theprogram))
                  (princ (strcat "\n<<< Lisp command \"" opt "\" found at "  theprogram " >>>"))
                )          	 
  (princ)
  )

 

If you want the lisp file to load as well , remove the two ";;"  

 

pBe

 

0 Likes
Message 27 of 30

vishshreevT578L
Advocate
Advocate

INITGET HERE IS BOUNDING ME WITH THE ONLY OPTIONS A B C, I TRIED GETSTRING BUT IT IS NOT WORKING

Shreev
0 Likes
Message 28 of 30

pbejse
Mentor
Mentor
Accepted solution

remove the (initget "a b c") and replace getkword with getstring then you're all set.

 

Have fun coding.

 

0 Likes
Message 29 of 30

vishshreevT578L
Advocate
Advocate

"PBEJSE" Thanx so much......Sir

Shreev
0 Likes
Message 30 of 30

vishshreevT578L
Advocate
Advocate

SIR IT IS NOT SEARCHING IN THE SUB FOLDER

Shreev
0 Likes