My idea is, with usage of OpenDCL:
a) set a varable to TRUE - Start an (endless) loop "while 'var = true'"
b) use another lisp which sets the variable to NIL - loop a) will stop
here is the code, with OpenDCL-Buttons:
;;;######################################################################
(defun c: btn_start_OnClicked (/)
(setq runflag 1)
(while runflag
(dos_pause 3)
(if (findfile "ja.txt")
(dos_msgbox "Hier .." "Hauptroutine" 1 3 1)
(dos_msgbox "Weg .." "Hauptroutine" 1 3 1)
)
)
)
;;;######################################################################
(defun c:_btn_stop_OnClicked (/)
(setq runflag nil1)
)
The idea is fine - but worthless, because a second lisp can not be started while the first lisp is still active ....
Any ideas for
- a solution with OpendDCL and DosLib or
- a solution in pure Lisp
Hello, Peter2,
as far as I know it won't work, because as long the while-loop is running nothing else can be started.
You could do something using LISP with C# behind. I've written such a thing: starting a C# based LISP function as a listener and an event will be fired when a certain state is reached.
================== snipping ====================
- call lisp function to start filesearch on vpn network storage in a seperate thread to avoid AutoCAD is getting locked for the meantime
- once the first file was found, an event file_was_found is send to AutoCAD
- once a file was clicked by the user, an event file_was_selected is send to AutoCAD
================== snipping ====================
LISP always is "single-lined". So you will have to rearrange your code in order to change the algorythm.
Regards, Fred
Hi, Peter2, it's me again:
using the (dcl_DelayedInvoke intDelayMilliseconds [als Long] strLispFunctionName [als String])
function you can build a "tester", if a certain state is reached:
(defun c:command1()
(dcl_DelayedInvoke 500 "c:command2")
); command1
(defun c:command2()
(if (not (findfile "c:\\myfile.txt)) (c:command1))
); command2
Just a thought. Give it a try!
Regards, Fred
Hi Fred
thanks for your posts. I will continue this week, but I suspect that your last code will do the same as mine: It loops endless, because also the "delay" is a lisp-command which can not be broken by another ...
Another idea could be that the lisp-loop checks a registry which is modified by an external registry-command, but this will result in "two applications" - one lisp inside AutoCAD, on registry outside. Possible, but maybe not the best.
My current try is to display a message-box after every loop. It is displayed for 2 seconds, and if you press "Cancel" it will cancel or it will continue. Normally a loop for 2 seconds is unacceptable, but in this case it could be a way - but not the best one, I would still prefer a standard "Stop the loop - button".
Hm, would it be a solution to build a .net dll with a feature I mentioned above?
I'm not sure whether OpenDCL should solve that or not....
Regards, Fred
Quote from: Fred Tomke on October 24, 2013, 01:18:37 PM
Hm, would it be a solution to build a .net dll with a feature I mentioned above?....
I'm not sure what exactly you mean, but yes - it seems that a solution outside of Lisp (reg-files, AHK-exe, .net) has to cooperate with Lisp. As already mentioned I don't want (but maybe I have to ..) two applications running, and creating a .net dll is not my knowledge. Maybe AHK ...
Hi, Peter2, so in the end you will need a solution with lisp - especially if you think about using your app on different plattforms.
Since you've searched for a file in yout initial post, I thought about the FileSystemWatcher (http://dotnet-snippets.de/snippet/verzeichnis-ueberwachen-mit-dem-filesystemwatcher/146). When a.txt is created or deleted I would call an event in AutoCAD like it does when you press a button.
Regards, Fred
Hi Fred
sorry -I missed the notification. I will take a look within the next time, but C# is not my "core competence" (better: I don't know nothing ..)