Using OpenDCl-Dialogue for NON-Lisp commands?

Started by Peter2, December 11, 2013, 09:29:14 AM

Previous topic - Next topic

Peter2

As a follower of my question here "Breaking a Lisp-Loop with another Lisp"
http://www.opendcl.com/forum/index.php?topic=2046.msg10103#msg10103

I wrote
Quote from: Peter2 on October 17, 2013, 09:07:31 AM
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
...

The result of the thread was:
- no solution inside lisp
- "external way" is necessary to control this behaviour

-> so I should use an OpenDCl-Dialogue for Lisp and a second function (software, doubleclick on reg..)

I'm not really confident that the following answer will be "Yes", but ...

"Is it possible to integrate a button / feature / event to an OpenDCL-Dialogue, that would start something (e.g. change registry-value or runs an exe) while(!!) an endless loop in running in Lisp?"

High-end-solution like "compiled C++ event-tracking-handler in combination with ......" are over my level ...

The reason for my question is "user friendly handling" - I want to present the user one single dialogue and not a collection of commands in different dialogues ..

Have a nice day!
Peter
ODCL 8.1.... German, AutoCAD 2017 - 2018, Win 7 x64, Win 10

owenwengerd

I didn't understand your overall goal before, and I still don't have any idea what the underlying problem is that you're trying to solve. I can only answer that yes, technically it is possible to "start something" within an endless loop. An OpenDCL event handler is a good example. A modal dialog is an endless loop. An event handler for a modal dialog control runs "inside" that endless loop.

Peter2

Hi Owen

thanks for your reply. I will try to explain with a simple example:

- Make a mode-less dialogue.
- Add Buttons "Start loop" and "Stop loop".

- "Start loop" starts a lisp (pseudocode):
Code (autolisp) Select
set myregistry = 1
while myregistry = 1
wait 5 sec
princ "I'm looping."


- "Stop loop" starts a lisp  or an exe or ....(pseudocode):
Code (autolisp) Select
set myregistry = 0

How to make it?

Thanks for hints and ideas.
Peter
ODCL 8.1.... German, AutoCAD 2017 - 2018, Win 7 x64, Win 10

owenwengerd

I think it will be easier to discern the problem if you provide real code instead of pseudocode (and describe how it fails).

Fred Tomke

Hi, guys,

I've attached a sample to demonstrate.
Maybe it does not describe exactly the practical case of Peter2 but it demonstrates the problem in general.


  • The start button call a function with a while loop.
  • AutoCAD does not leeave the while loop until the condition will result in false.
  • Meanwhile no other event or command is recognzied.
  • So I have not the possibility to stop the loop by pressing a button (to cancel a progress).
  • In my experiences, even parallel C#-threads/backgroundworkers only start after the calling method/event (startbutton event) has finished.

Regards, Fred
Fred Tomke
Dipl.-Ing. (FH) Landespflege

[ landscaper - landscape developer - digital landscape and urban design]

Fred Tomke

Hello, I've attached a new lisp to demonstrate a solution without a while-loop.
Regards, Fred
Fred Tomke
Dipl.-Ing. (FH) Landespflege

[ landscaper - landscape developer - digital landscape and urban design]

owenwengerd

Thanks Fred, I suspect you are correct about the problem. If so, the issue is really about allowing Windows to process messages from within an AutoLISP loop. The (dcl_SendString) or (dcl_DelayedInvoke) functions are good ways to do that.

Peter2

Thanks both for the postings

if I see it right the second solution with the "self-recursive-dcl_DelayedInvoke 1000" is the solution, right?

Peter
Peter
ODCL 8.1.... German, AutoCAD 2017 - 2018, Win 7 x64, Win 10

Fred Tomke

Fred Tomke
Dipl.-Ing. (FH) Landespflege

[ landscaper - landscape developer - digital landscape and urban design]

Peter2

Thanks a lot, Fred. I hope I will bring it to start within the next weeks.
Peter
ODCL 8.1.... German, AutoCAD 2017 - 2018, Win 7 x64, Win 10

Peter2

Additional info:

Command "dos_getcancel" from DosLib also does the trick: it can break a "while-loop"
http://www.en.na.mcneel.com/doslib/interface_functions/dos_getcancel.htm
Peter
ODCL 8.1.... German, AutoCAD 2017 - 2018, Win 7 x64, Win 10

owenwengerd

Apparently I did not understand the problem you're trying to solve. As I suggested earlier, actual code that demonstrates would be more clear. If you just want to display a modeless dialog with a cancel button that closes the dialog, that is pretty simple to do. Then you can check inside your while loop whether the dialog is still open.

Peter2

Hi Owen

I'm sorry that I'm still not able to express myself good enough, but I thought that Fred' postings and examples above could explain and solve my problem. He showed that a "while-loop" could not be cancelled from OpenDCL, and with his other example he showed that a loop with a "self-calling-function" could to the trick.

I tried only to give an additional info that the mentioned DosLib-Function could also break a while loop.
Peter
ODCL 8.1.... German, AutoCAD 2017 - 2018, Win 7 x64, Win 10

owenwengerd

I think the issue is in what you mean by "break a while loop". Neither OpenDCL nor (dos_getcancel) can break a while loop. In either case, it is the code inside the while loop itself that decides when to break out of the loop. It seems your question is more about how to program a while loop that breaks when some condition is met.

My previous responses (and I think Fred's) were about processing Windows messages while a long process (i.e. a while loop) completes.

Peter2

Hi Owen

Quote from: owenwengerd on January 01, 2014, 03:05:08 PM
I think the issue is in what you mean by "break a while loop". Neither OpenDCL nor (dos_getcancel) can break a while loop....
Yes, of course you are right.

My basic question should be formulated:
QuoteHow to modify the condition of a "while-loop"
- via a dialogue and
- while the loop is Ã,¨looping'

The current answers are:
a) (dos_getcancel) can be used for a "while-loop"
b) Fred's self-recursive loop (see above) makes a loop without (while) which accepts modifications of conditions

I hope it is clearer now.(?)
Peter
ODCL 8.1.... German, AutoCAD 2017 - 2018, Win 7 x64, Win 10