OpenDCL Forums

OpenDCL => Runtime/AutoLISP => Topic started by: Peter2 on December 11, 2013, 09:29:14 AM

Title: Using OpenDCl-Dialogue for NON-Lisp commands?
Post by: Peter2 on December 11, 2013, 09:29:14 AM
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!
Title: Re: Using OpenDCl-Dialogue for NON-Lisp commands?
Post by: owenwengerd on December 11, 2013, 09:50:20 AM
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.
Title: Re: Using OpenDCl-Dialogue for NON-Lisp commands?
Post by: Peter2 on December 11, 2013, 11:10:09 AM
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.
Title: Re: Using OpenDCl-Dialogue for NON-Lisp commands?
Post by: owenwengerd on December 11, 2013, 11:32:02 AM
I think it will be easier to discern the problem if you provide real code instead of pseudocode (and describe how it fails).
Title: Re: Using OpenDCl-Dialogue for NON-Lisp commands?
Post by: Fred Tomke on December 11, 2013, 12:30:22 PM
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.


Regards, Fred
Title: Re: Using OpenDCl-Dialogue for NON-Lisp commands?
Post by: Fred Tomke on December 11, 2013, 12:48:22 PM
Hello, I've attached a new lisp to demonstrate a solution without a while-loop.
Regards, Fred
Title: Re: Using OpenDCl-Dialogue for NON-Lisp commands?
Post by: owenwengerd on December 11, 2013, 01:11:50 PM
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.
Title: Re: Using OpenDCl-Dialogue for NON-Lisp commands?
Post by: Peter2 on December 12, 2013, 03:04:03 PM
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
Title: Re: Using OpenDCl-Dialogue for NON-Lisp commands?
Post by: Fred Tomke on December 12, 2013, 03:54:08 PM
Yes, that's it!
Regards, Fred
Title: Re: Using OpenDCl-Dialogue for NON-Lisp commands?
Post by: Peter2 on December 15, 2013, 01:37:16 PM
Thanks a lot, Fred. I hope I will bring it to start within the next weeks.
Title: Re: Using OpenDCl-Dialogue for NON-Lisp commands?
Post by: Peter2 on January 01, 2014, 12:17:52 PM
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
Title: Re: Using OpenDCl-Dialogue for NON-Lisp commands?
Post by: owenwengerd on January 01, 2014, 01:01:51 PM
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.
Title: Re: Using OpenDCl-Dialogue for NON-Lisp commands?
Post by: Peter2 on January 01, 2014, 02:07:13 PM
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.
Title: Re: Using OpenDCl-Dialogue for NON-Lisp commands?
Post by: 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. 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.
Title: Re: Using OpenDCl-Dialogue for NON-Lisp commands?
Post by: Peter2 on January 02, 2014, 03:38:22 AM
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.(?)
Title: Re: Using OpenDCl-Dialogue for NON-Lisp commands?
Post by: owenwengerd on January 02, 2014, 06:59:50 AM
Inside a while loop, you can use (and MyProject_Myform (dcl_Form_IsActive (http://www.opendcl.com/HelpFiles/index.php?page=Reference/Method/Form/IsActive.htm) MyProject_MyForm)) to check whether a modeless form is still active. Does that help?
Title: Re: Using OpenDCl-Dialogue for NON-Lisp commands?
Post by: Peter2 on January 02, 2014, 07:10:36 AM
I will see, but not immediately, because the project is delayed. I will report later.