1. RE: debugging

tone.skoda at siol.net wrote:
> is there a way i can tell interperer which routine should it call when 
> program crashes?
> 
> i thought about re-defining crash_message () but i dont think it would 
> work
> 
> i want to open with notepad my debug.txt file in which i was writing 
> debug info at program crash
> 

tone:

You could set your crash_message to tell your user to type
in the name of a batch program which would execute notepad
with the name of the text file that is defined by crash_file. 

Bernie

new topic     » topic index » view message » categorize

2. RE: debugging

tone skoda wrote:

>is there a way i can tell interperer which routine should it call when 
>[the] program crashes?

First, I hope this complies with the Euphoria source license:

  You can publicly discuss the algorithms used by our source
  code in open forums, and you can mention the names of C
  routines, variables and other identifiers in the code, but
  you must not reveal actual lines of source code.


Anyway, if you had the interpreter source, I'd guess it would not be too 
difficult to add in. The external definition might look like:

   global sub set_crash_routine( int id )
      machine_proc( M_CRASH_ROUTINE, call_back(id) )
   end sub

Define M_CRASH_ROUTINE in execute.h, and add it to the case statement in 
machine.c. It would just have to assign the value to some global variable, 
crash_routine.

Look in rterror.c for CleanUpError, which handles most of the errors. Before 
handling crash_message, add something like this:

   /* did the user set a crash routine? */
   if (crash_routine != NULL && crash_called == 0) {

      /* clear flag - love that name! */
      gameover = 0;

      /* prevent from being called multiple times */
      crash_called++;

      /* call the function pointer */
      (void crash_routine)(void);

      /* restore flag */
      gameover = 1;
   }

Something like that, anyway. No doubt, there's bound to be a nasty 
side-effect here I didn't take into account...

If I figure out the correct cast for the function pointer, I might give it a 
try.

-- David Cuny

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu