@@ -34,6 +34,10 @@ along with LiveCode. If not see <http://www.gnu.org/licenses/>. */
3434#include " mcerror.h"
3535#include " param.h"
3636
37+ #include " chunk.h"
38+ #include " scriptpt.h"
39+ #include " osspec.h"
40+
3741// //////////////////////////////////////////////////////////////////////////////
3842
3943MC_EXEC_DEFINE_EXEC_METHOD (Debugging, Breakpoint, 2 )
@@ -60,6 +64,8 @@ MC_EXEC_DEFINE_SET_METHOD(Debugging, WatchedVariables, 1)
6064
6165MC_EXEC_DEFINE_EXEC_METHOD(Debugging, Assert, 3 )
6266
67+ MC_EXEC_DEFINE_EXEC_METHOD(Debugging, PutIntoMessage, 2 )
68+
6369// //////////////////////////////////////////////////////////////////////////////
6470
6571void MCDebuggingExecDebugDo(MCExecContext& ctxt, MCStringRef p_script, uinteger_t p_line, uinteger_t p_pos)
@@ -456,3 +462,92 @@ void MCDebuggingExecAssert(MCExecContext& ctxt, int type, bool p_eval_success, b
456462
457463 ctxt . GetObject () -> message (MCM_assert_error, &t_handler);
458464}
465+
466+ // //////////////////////////////////////////////////////////////////////////////
467+
468+ void MCDebuggingExecPutIntoMessage (MCExecContext& ctxt, MCStringRef p_value, int p_where)
469+ {
470+ if (!MCS_put (ctxt, p_where == PT_INTO ? kMCSPutIntoMessage : (p_where == PT_BEFORE ? kMCSPutBeforeMessage : kMCSPutAfterMessage ), p_value))
471+ ctxt . LegacyThrow (EE_PUT_CANTSETINTO);
472+ }
473+
474+ static MCObject *getobj (MCExecContext& ctxt, MCStringRef p_string)
475+ {
476+ MCObject *objptr = NULL ;
477+ MCChunk *tchunk = new (nothrow) MCChunk (False);
478+ MCerrorlock++;
479+ MCScriptPoint sp (p_string);
480+ if (tchunk->parse (sp, False) == PS_NORMAL)
481+ {
482+ uint4 parid;
483+ tchunk->getobj (ctxt, objptr, parid, True);
484+ }
485+ MCerrorlock--;
486+ delete tchunk;
487+ return objptr;
488+ }
489+
490+ void MCDebuggingSetMessageBoxRedirect (MCExecContext& ctxt, MCStringRef p_target)
491+ {
492+ MCObject *t_object;
493+ t_object = getobj (ctxt, p_target);
494+
495+ if (t_object != NULL )
496+ MCmessageboxredirect = t_object -> GetHandle ();
497+ else
498+ MCmessageboxredirect = nil;
499+ }
500+
501+ void MCDebuggingGetMessageBoxLastObject (MCExecContext& ctxt, MCStringRef& r_object)
502+ {
503+ if (MCmessageboxlastobject.IsValid ())
504+ {
505+ bool t_success;
506+
507+ MCAutoStringRef t_obj, t_long_id;
508+ MCAutoValueRef t_id_value;
509+ t_success = MCStringCreateMutable (0 , &t_obj);
510+
511+ if (t_success)
512+ t_success = MCmessageboxlastobject->names (P_LONG_ID, &t_id_value);
513+ if (t_success && ctxt . ConvertToString (*t_id_value, &t_long_id))
514+ t_success = MCStringAppendFormat (*t_obj, " %@,%@,%u" , *t_long_id, MCNameGetString (MCmessageboxlasthandler), MCmessageboxlastline);
515+
516+ if (t_success && MCmessageboxlastobject->getparentscript () != nil)
517+ {
518+ t_success = MCmessageboxlastobject->getparentscript ()->GetObject ()->names (P_LONG_ID, &t_id_value);
519+ if (t_success && ctxt . ConvertToString (*t_id_value, &t_long_id))
520+ t_success = MCStringAppendFormat (*t_obj, " ,%@" , *t_long_id);
521+ }
522+ if (t_success && MCStringCopy (*t_obj, r_object))
523+ return ;
524+ }
525+ else
526+ {
527+ r_object = MCValueRetain (kMCEmptyString );
528+ return ;
529+ }
530+
531+ ctxt . Throw ();
532+ }
533+
534+ void MCDebuggingGetMessageBoxRedirect (MCExecContext& ctxt, MCStringRef& r_id)
535+ {
536+ if (MCmessageboxredirect.IsValid ())
537+ {
538+ MCAutoValueRef t_long_id;
539+ if (MCmessageboxredirect -> names (P_LONG_ID, &t_long_id) &&
540+ ctxt . ConvertToString (*t_long_id, r_id))
541+ return ;
542+ }
543+ else
544+ {
545+ r_id = MCValueRetain (kMCEmptyString );
546+ return ;
547+ }
548+
549+ ctxt . Throw ();
550+ }
551+
552+
553+
0 commit comments