News:

Please note new Forum URL: forum.designcad.com

Main Menu
DesignCAD 3D Max 2027 box
Now available

DesignCAD 2027

Hatches that follow their boundaries, an on-screen dial to turn your model, and a way to find any command by name, in a clean Windows 11 look.

Basicad "ON ESC" new-statment

Started by JJG, January 08, 2012, 03:25:19 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

JJG

I know it's not the good topic for, but to be sure it will not been forgotten, I create this new one.

I remind you that it's in connection with the topic  http://forum.designcad.com/index.php?topic=3715.0  , where I proposed :

to create a new basicad statment :
"ON ESC" statment
on the same model as ON ERROR,
that would operate in the way, ie. if a hit of Esc-key is encountered during the execution of the macro, this will cause directly the execution to be transfered to the specified label (the name you wish). then, macro execution will continue from the label until an END statment (or eventualy a RESUME statment) is encountered.

Dr PR

I see a serious problem with this idea. ESCape should be reserved only to terminate operations. Period.

If you could redefine the ESCape key to do something else you might make it impossible to get out of endless loops. Or make it impossible to terminate extremely long redraws.

Rather than "ON ESCAPE" why not implement "ON KEY" where the defined key (or key combination) is anything except ESCape?

Phil
DesignCAD user since 1987

paulerens

#2
Quote from: Dr PR on January 08, 2012, 02:34:19 PM
f you could redefine the ESCape key to do something else you might make it impossible to get out of endless loops. Or make it impossible to terminate extremely long redraws.
If You could redefine the ESCape key to do something else (such as on-error) You Might make it Possible to get out of endless loops and make it Possible to terminate extremely fast.
However, the problem is to terminate the program immediately after ESCape.I think.And before, you can't send the program to nowhere.

Paul.

Dr PR

Paul,

My concern is that some functions can be terminated with the ESCape key. If you have an "On ESCape" function and press the key it will be unpredictable whether a function processes the key and stops or whether the macro On ESC function will process the key.

I think it would be much better to avoid this problem with an "On Key" function to allow macro execution to be redirected by any key but ESCape.

I confess that I know very little about the mechanics of macro execution, so maybe this cannot be a problem. But unless it can be proven that multiple definitions of action for the ESCape key cannot be a problem, I think this should be avoided.

Phil
DesignCAD user since 1987

paulerens

Phil and JJG,
Next text is available in the macro language reference.
996 - Enhanced Esc Key Behavior
[0 (default) -- Esc key behaves normally- if pressed during a drawing command (such as Circle or Line), it terminates that command and offers the chance to end the entire macro. If pressed in the middle of a batch of macro language operations, it ends the macro immediately.

1 (enhanced) -- Esc key opens "do you want to quit?" dialog box. Answer "No" resumes operation without skipping any commands. Answer "Yes" terminates the macro. If Esc is pressed during a drawing command (such as Circle or Line), that command is NOT terminated if the user answers "No"- you must either complete the command or end the entire macro.]

You can turn Sys(996) off and on for different parts of your macro. If you CHAIN to another macro, the current setting of Sys(996) is lost; the new macro assumes default behavior unless there is code that specifically turns on the enhanced mode.


Since the program first terminated the algorithm , and if that's a loop.!
Yes .... then you know!!

Paul

JJG

Dr Pr, please read the topic  http://forum.designcad.com/index.php?topic=3715.0  again, where all the concept was described and explained.

Paulerens, yes (of course) I knew what we can actually do with sys(996), and so it's presicely to have the possibility to do some things we can not do actually, that I have suggered this way, which seems to be the easiest.

Dr PR

JJG,

My initial concern remains. What does ESCape terminate? If you press ESCape while a function is running and it terminates the function, does it also terminate the macro? With the current options 0 and 1 you have ambiguity about whether or not the function and macro are terminated.

With option 0 if you press the Escape key it will either terminate a function or terminate the macro, but you can't always predict which it will be. If it terminates a command you have the option to continue the macro. You don't want to restore variables if just the function is terminated because the macro will still be running. So somehow your macro must know the conditions before the ESCape key was pressed.

With option 2 when you press ESCape you don't know if a command has paused or the macro has paused. Say "NO" and operations will continue and you don't want the variables restored.

So unconditional restoration of your variables when ESCape is pressed is undesirable with these options.

Your proposed third "GO TO" option is an unconditional bail out of any command in progress and possibly bail out of the macro, depending upon the code at the label it goes to. Great, but the drawing may have been modified to an unpredictable extent before ESCape was pressed. Restoring variables to a screwed up drawing doesn't seem to me to be very helpful.

This is why the functioning of ESCape processing must be examined carefully to be sure that you don't really mess up the drawing.

It would be MUCH safer to save the drawing with variables before executing the macro. It would be MUCH safer to use any key other than ESCape to cause the "GO TO" and then execute whatever steps you want to do to restore variables - like reload the previously saved drawing. What is wrong with this idea?

Phil
DesignCAD user since 1987

JJG

Dr Pr, thank's for the reflexion.

You have wanted to study all possible cases when you press the Escape key while running the macro: OK, no problem ! and I'm agreed with.

But you seem to have lost sight of the reason for the request : allow to go directly to a sub-routine (i. e. a label) (for example ...) which will restore the parameters as they were before the Start up of the macro, because if not, you lose all those that were changed during the execution of the macro to press the "esc".

And I do not think it would come of anyone the idea or the reflex to press a key other than "esc" to stop (in emergency) the execution of a macro, or other control.
It is therefore only the possibility to have an additional option for the effect of the "esc" key, and only in a macro.
That why I think a new statment such as "ON ESC" is better that a sys(996)=2 option, since it will work such as the ON ERROR statment.


Finally (I say this in jest, of course), it is clear that rather than using macros that will allow you to make in only "one-click" all the work you want, you can also continue to do this job "by hand", so you don't need to seek solutions to simplify life and to be much performant ...

Feel free to use it or not !

Here, another example (which already exists in basicad) :  with basicad, you have the possibility to write a macro that will create some new files, with the name you want and where you want in Windows ;
so, nothing prevents you from writing a file in the windows system-area, with a name that already exists, and that can drive your system to become completely blocked and unusable ... it's up to you to know what you do, and use the tools knowingly.

With a car, it's the same, nothing prevents you from driving into the ditch ...

Sometimes I have some difficulties to understand you ! : it's like your "allergy" for dimensions since V17, or nested groups ...
But apart from that, I admire you a lot and thank you very much for all your tips and tricks of all kinds, which show that you are a true expert in DesignCAD and more generaly in CAD.

Rob S


Quoteyour "allergy" for dimensions since V17,
;D

I have on occasion admittedly wondered what that was - now it has a name!!!
User since forever

Dempsey

I am late jumping into this discussion, but here my are two bits worth after reading this topic and the one from June 2011.


  • Implement ON ESC function like ON ERROR. ON ESC gives control to some code in the macro to "clean up" like restoring saved values. A flag can be set when values have been saved at initialization and this flag can be checked prior to restoring those saved values.
  • SYS(996) and ON ESC need to work together. Perhaps SYS(996) = 2 can be used to "activate" the ON ESC functionality, but if there is no ON ESC executed then it automatically falls back to the behavior as if SYS(996) = 1.
Dempsey

paulerens

In my opinion you can not interrupt a program in C + + with BasicCad.

Dr PR

JJG,

I do see your point about restoring variables. Your original purpose for the ON ESC was to restore variables that had been changed during execution of the macro to what they were before macro execution. That is a goosd idea.

I also agree that the ESCape key is the "natural" action to terminate a macro.

However, I have been working with computers (hardware and software design) for decades, and just about the worst possible thing to debug is code that works one way this time, another way the next time, and yet another way when the moon is full.

IFF you can implement the ON ESC in such a way that there is no ambiquity in how it works every time it will be a good addition. I wish you luck.

****

As for dimensions, I have drawings made with V15 and V17 with more than 3000 dimensions per drawing. Some took years to complete. They are a mess when opened in the later DesignCAD versions. They are a part of a decade long project, made up of dozens of drawings with tens of thousands of dimensions. If I have to go back and check every dimension in every drawing it will take weeks or months. DesignCAD may now be AutoCRUD compatible, but it is no longer DesignCAD compatible! That is my complaint. In addition, text positioning is not as easy or as versatile as it was in the older versions. If the bugs are ever worked out of the new dimensions I will be happy again. It hasn't happened yet.

Nested groups are perhaps the worst implemented feature I have ever seen in any program. They allow you to create hidden and unselectable objects on layers having no elements of the associated groups - that is just stupid! For what it is worth, I started requesting nested groups in the early 1990s. I have no idea how many letters, phone calls and emails I have made to DesignCAD tech support requesting this feature (before the Forum came along). I kept it up for many, many years, and was absolutely delighted when nested groups were finally added - for about a month. Then I started having all sorts of selection and zooming problems. This was so bad that DT provided the K34.d3m macro to purge the hidden nested group element to repair corrupted drawings. This is why the program has the option to disable nested groups, and asks if you want to disable them when a file is opened containing nested groups. If you use multiple layers and nested groups you will eventually learn what I am fussing about the hard way. You can end up with parts of your drawings that cannot be selected (so you can't edit them, move them or delete them). If nested groups are ever implemented correctly I will stop complaining.

Phil
DesignCAD user since 1987

JJG

OK, thank you for your reply !

Concerning dimensions, at the first time, like you, I was very astonished when I discovered this in the french version V18.33, as beta one. And my first remark was that the extended dimensions was working so completely aberrant (it was needed to place the position of dimensions as the first point ... !!!) etc ...
But after 2 weeks with reports and discussions with the technical service of Cogistem (french distributor of Designcad), we came to implant updated patch, and all works now very well ; more, the technical service of Cogistem had developped a very simple and practical VBA-programm (as plug-in) for the setting of dimensions in one or max 3 "clics" ... long before any macros that you can find for this on this forum.

Now, for nothing I will not return to the V15 system, which also had many disadvantages (if only that with the mirror-functions, etc ...) which are all fixed now, and most importantly, an export to DWG retains the dimensions in ... dimensions, no more arrows, vectors and text.

OK ?

Now concerning nested groups :
In the french version of Designcad (pro 7000, and now pro 8000), we have the "visibility by host layer" in the infobox (I mentioned this in another topic), which resolves all kinds of problems that your are speeking from ... why the americain-version does not want from this function ?? that is something I can not understand too ... especially there is a similar function for blocks and symbols !!!
And for me too, for nothing I will not return to the V15 system, i. e. without the nested groups.

Again, the user has to want of what he does with his tools.
In the woodwork (field concerned in the company where I work), nothing prevents you from cutting yourself with the tools ... it is up to you to learn to use it properly and wisely !

Spread the word!

Same as for Designcad tools.

bdeck

I vote for an  ON EVENT trap to catch any keystroke, mouseclick, or mouse movement.

Catch everything and throw back what you dont want.

But I woud settle for adding a way to decode R & L mouse clicks after an anykey statement.

Adding an ON ESCAPE to an improved anykey (for the reasons stated by jjg) would do most of what I need, and would result in much simpler code.

As in the prior thread, I would add that if an ON ESC command is to be implemented it should not interfere with the ANYKEY statement, which I routinely use to process the ESC key.

BD

JJG

It's true that I never thought about an "ON EVENT" statment, as you suggest, that would "cover" and "include" the case of "ON ESC "...
This will be even more powerful !