Page 1 of 1

getmode bug?

PostPosted: Sun Sep 30, 2018 4:52 pm
by dhs
I have a Classic DCAL macro that uses getmode, and it is crashing (fault 10 Error from: 736) if the user presses certain keys such as 'M' or 'C' etc.
Can anybody tell me what is wrong with the following code:
Code: Select all      if cvr then
         res := getmode ('cover', mode, key);
      else
         res := getmode ('uncover', mode, key);
      end;
      if res = res_escape then
         if key = f9 then
            cvr := true;
         elsif key = f0 then
            cvr := false;
         elsif key = s9 then
            ShowAbout;
         elsif key = s0 then
            done := true;
         else
            beep;
         end;
      elsif res = res_normal then
         !process entities using normal ent_first/ent_get/ent_next loop
      end;
               


(Full source code is available at http://www.dhsoftware.com.au/source/cover_source.zip).

The code was written very quickly, so I expect I have missed something, but I can't see the problem right now ...
Thanks for any input.

Re: getmode bug?

PostPosted: Mon Oct 01, 2018 7:11 am
by David A. Giesselman
David,

Looking through the full source, it is missing the line:

Code: Select allelsif res = res_normal then

Dave

Re: getmode bug?

PostPosted: Mon Oct 01, 2018 6:02 pm
by dhs
Thanks for the response Dave,
I forgot that I changed 'else' to 'elsif res= res_normal' in the code after I uploaded the source zip file to my website.

The original 'else' logic assumed that there were only 2 possible values for res (res_escape and res_norma)l ... in hindsight probably not a valid assumption. On reviewing it after discovering the crash scenario I changed it to the elsif logic in the code I pasted in my original post. I could have sworn I tested the compiled macro with the new elsif logic logic and it still exhibited the crash ... but recompiling now it seems ok. I was in a bit of a hurry and probably tested the wrong version .... sorry to have worried you.

Re: getmode bug?

PostPosted: Tue Oct 02, 2018 1:21 am
by dhs
ok, I need to take back half of what I said in my previous post: I did test a newly compiled version with the 'elsif res=res_normal' logic just before my previous post and it did not crash when I pressed 'M'.
HOWEVER, every subsequent time I have tested it does still crash with the 10 from 736 error.

To help to debug it I tried adding a getint after the call to getmode:
Code: Select all      if cvr then
         res := getmode ('cover', mode, key);
      else
         res := getmode ('uncover', mode, key);
      end;
getint (res);

The result of this was not what I expected: After pressing 'm' getint was called displaying a value of 1 (i.e. res_escape). After accepting the input (without changing it from 1) the macro continued without crashing, but it did not invoke the move functionality. If I pressed 'M' (i.e. shift/m) then getint was called displaying a value of 0 (i.e. res_normal) and once I accepted the input the macro displayed a message of 'No polylines were processed' (consistent with the res_normal result with no polylines selected). But most interesting was when I tried pressing Alt/s (which I expected to invoke the stretch menu) - the getint call displayed a blank value in this case).
In all of the above cases I would have expected the macro to exit from the getmode call because I expected it to process the global escape key (although in the case of Alt/s I expected it to return to the macro after stretch processing was completed (this actually worked in the original macro)

Next I tried placing a pause after the call to getmode:
Code: Select all      if cvr then
         res := getmode ('cover', mode, key);
      else
         res := getmode ('uncover', mode, key);
      end;
pause (0.2);

I tried values of 0.2 and then 1.2 for the pause: in both cases the macro processed correctly (after the appropriate pause) when I pressed 'm' the first time I ran the newly compiled macro ... but every subsequent time I try pressing 'm' in the macro it crashes (after the pause) without displaying any error code at all. (if I recompile the macro then it again works the first time but then reverts to crashing each subsequent time I try the test).

Any advice you can offer would be appreciated.
Thanks,
David H.

Re: getmode bug?

PostPosted: Tue Oct 02, 2018 10:43 am
by David A. Giesselman
David,

Using your macro as a guide, I was able to identify the cause of the crash and have corrected it for the next update.

Dave

Re: getmode bug?

PostPosted: Tue Oct 02, 2018 3:01 pm
by dhs
Thanks Dave...