Author Topic: Automatic RELOADING of test lisp files  (Read 1072 times)

0 Members and 1 Guest are viewing this topic.

Grrr1337

  • Swamp Rat
  • Posts: 812
Automatic RELOADING of test lisp files
« on: October 20, 2016, 07:55:10 AM »
Hi guys,
Does anyone have experience with the issue I'm trying to figure out:
Code: [Select]
(defun C:testf ( / *error* rtn )

(defun *error* ( msg )
(if *LoadTestLspFilePath* (setq *LoadTestLspFilePath* nil)) ; not sure where to reset this variable to nil
(if (or (not (member msg '("Function cancelled" "quit / exit abort"))) (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*")) (princ (strcat "\nError: " msg)))
(princ)
); defun *error*

(if (or *LoadTestLspFilePath* (setq *LoadTestLspFilePath* (getfiled "Specify lisp file to load" "C:\\Users\\Grrr\\Desktop" "lsp" 0)))
(if (not (vl-catch-all-error-p (setq rtn (vl-catch-all-apply (function load) (list *LoadTestLspFilePath*)))))
(princ (strcat "\nLisp file is loaded!\n" rtn))
(princ (strcat "\nError occured:\n" (vl-catch-all-error-message rtn)))
)
)

(princ)
);| defun |; (or (vlax-get-acad-object) (vl-load-com)) (princ)
The above code does not work, I am posting it so you can have an idea what I am attempting, I get the following error:
Code: [Select]
Command:  TESTF
Error: bad argument type: stringp
I am trying thru this lisp code, once to prompt for a .lsp file to be loaded using (getfiled), and everytime when I want to reload it, just to call the command "testf".
The reason for that is that I prefer using notepad++ , if I don't have to debug and/or trace errors in the code (with VLIDE).
But everytime I make some modification I have to call "APPLOAD" to test the code again and again... which is very uncomfortable so I'm attempting such alternative.
(apply ''((a b c)(a b c))
  '(
    (( f L ) (apply 'strcat (f L)))
    (( L ) (if L (cons (chr (car L)) (f (cdr L)))))
    (72 101 108 108 111 32 87 111 114 108 100)
  )
)
vevo.bg

roy_043

  • Water Moccasin
  • Posts: 1895
  • BricsCAD 18
Re: Automatic RELOADING of test lisp files
« Reply #1 on: October 20, 2016, 08:15:27 AM »
First RTM on (vl-catch-all-apply). Then you should be able to debug this yourself.

Grrr1337

  • Swamp Rat
  • Posts: 812
Re: Automatic RELOADING of test lisp files
« Reply #2 on: October 20, 2016, 08:26:19 AM »
Hi Roy,
I've just fixed the issue I had:
Code: [Select]
; Usage:
; uppon calling (c:test) in ACAD, the user is prompted for a .lsp file for being automatically Reloaded
; after specifying the .lsp file, every time changes are performed in the test routine and they are saved in the text editor,
; just call (C:test) in ACAD to "ReTest" the routine.
; AutoReload .lsp function:
(defun C:test ( / *error* ans )

(defun *error* ( msg )
(if *ReLoadTestLspFilePath* (setq *LoadTestLspFilePath* nil))
(if (or (not (member msg '("Function cancelled" "quit / exit abort")))
(wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*")) (princ (strcat "\nError: " msg))
)
(princ)
); defun *error*

(if *ReLoadTestLspFilePath*
(progn
(initget "Yes No")
(setq ans (getkword "\nReset the test lisp file path? [Yes/No] <No>: "))
(if (not ans) (setq ans "No"))
(if (= "Yes" ans) (setq *ReLoadTestLspFilePath* nil))
)
)

(cond
( *ReLoadTestLspFilePath*
(load *ReLoadTestLspFilePath*)
(princ "\nLisp file is reloaded! ")
)
( (not *ReLoadTestLspFilePath*)
(if (setq *ReLoadTestLspFilePath* (getfiled "Specify test lisp file to load" "" "lsp" 0))
(load *ReLoadTestLspFilePath*)
)
)
(T nil)
); cond

(princ)
);| defun |; (or (vlax-get-acad-object) (vl-load-com)) (princ)

; Example test function structure (incase THIS .lsp file is chosen itself):
; (defun testfun ( / )
; (alert "\nChickens and eggs!")
; (princ)
; )
; (testfun)
Now I just save the above into some .lsp file, then "APPLOAD" it only once,
Then after each modification of the "test function" and "save" the changes I just recall the (C:test) into ACAD and this way imediatelly the "test function" routine can be tested.
I hope I'm not the only one that finds it useful.
« Last Edit: October 20, 2016, 09:29:15 AM by Grrr1337 »
(apply ''((a b c)(a b c))
  '(
    (( f L ) (apply 'strcat (f L)))
    (( L ) (if L (cons (chr (car L)) (f (cdr L)))))
    (72 101 108 108 111 32 87 111 114 108 100)
  )
)
vevo.bg