@@ -527,6 +527,101 @@ void MCDispatchCmd::exec_ctxt(MCExecContext &ctxt)
527527 MCKeywordsExecTeardownCommandOrFunction (params);
528528}
529529
530+ MCLogCmd::~MCLogCmd (void )
531+ {
532+ while (params != NULL )
533+ {
534+ MCParameter *t_param;
535+ t_param = params;
536+ params = params -> getnext ();
537+ delete t_param;
538+ }
539+ }
540+
541+ Parse_stat MCLogCmd::parse (MCScriptPoint& sp)
542+ {
543+ initpoint (sp);
544+
545+ if (getparams (sp, ¶ms) != PS_NORMAL)
546+ {
547+ MCperror -> add (PE_STATEMENT_BADPARAMS, sp);
548+ return PS_ERROR;
549+ }
550+
551+ /* If there are any parameters then compute the number of containers needed
552+ * to execute the command. */
553+ if (params != nullptr )
554+ {
555+ container_count = params->count_containers ();
556+ }
557+
558+ return PS_NORMAL;
559+ }
560+
561+ // This method follows along the same lines as MCComref::exec
562+ void MCLogCmd::exec_ctxt (MCExecContext &ctxt)
563+ {
564+ // no-op if logMessage is empty
565+ if (MCNameIsEmpty (MClogmessage))
566+ {
567+ return ;
568+ }
569+
570+ /* Attempt to allocate the number of containers needed for the call. */
571+ MCAutoPointer<MCContainer[]> t_containers = new MCContainer[container_count];
572+ if (!t_containers)
573+ {
574+ ctxt.LegacyThrow (EE_NO_MEMORY);
575+ return ;
576+ }
577+
578+ /* If the argument list is successfully evaluated, then do the dispatch. */
579+ if (MCKeywordsExecSetupCommandOrFunction (ctxt,
580+ params,
581+ *t_containers,
582+ line,
583+ pos,
584+ false ))
585+ {
586+ if (!ctxt.HasError ())
587+ {
588+ ctxt.SetLineAndPos (line, pos);
589+ MCHandler * t_handler = nullptr ;
590+ MCKeywordsExecResolveCommandOrFunction (ctxt, MClogmessage, false , t_handler);
591+ MCKeywordsExecCommandOrFunction (ctxt, t_handler, params, MClogmessage, line, pos, false , false );
592+ }
593+ }
594+
595+ /* Clean up the evaluated argument list */
596+ MCKeywordsExecTeardownCommandOrFunction (params);
597+
598+ if (MCresultmode == kMCExecResultModeReturn )
599+ {
600+ // Do nothing!
601+ }
602+ else if (MCresultmode == kMCExecResultModeReturnValue )
603+ {
604+ // Set 'it' to the result and clear the result
605+ MCAutoValueRef t_value;
606+ if (!MCresult->eval (ctxt, &t_value))
607+ {
608+ ctxt.Throw ();
609+ return ;
610+ }
611+
612+ ctxt.SetItToValue (*t_value);
613+ ctxt.SetTheResultToEmpty ();
614+ }
615+ else if (MCresultmode == kMCExecResultModeReturnError )
616+ {
617+ // Set 'it' to empty
618+ ctxt.SetItToEmpty ();
619+ // Leave the result as is but make sure we reset the 'return mode' to default.
620+ MCresultmode = kMCExecResultModeReturn ;
621+ }
622+ }
623+
624+
530625Parse_stat MCMessage::parse (MCScriptPoint &sp)
531626{
532627 initpoint (sp);
0 commit comments