Example #1
0
void MCArraysEvalMatrixMultiply(MCExecContext& ctxt, MCArrayRef p_left, MCArrayRef p_right, MCArrayRef& r_result)
{
	// MW-2014-03-14: [[ Bug 11924 ]] If both are empty arrays, then the result
	//   is empty.
    if (MCArrayIsEmpty(p_left) && MCArrayIsEmpty(p_right))
    {
        r_result = MCValueRetain(kMCEmptyArray);
        return;
    }
    
    // MW-2014-03-14: [[ Bug 11924 ]] If either array is empty, then its a mismatch.
	MCAutoPointer<matrix_t> t_left, t_right, t_product;
	if (MCArrayIsEmpty(p_left) || MCArrayIsEmpty(p_right) ||
        !MCArraysCopyMatrix(ctxt, p_left, &t_left) || !MCArraysCopyMatrix(ctxt, p_right, &t_right) ||
		!MCMatrixMultiply(*t_left, *t_right, &t_product))
	{
		ctxt.LegacyThrow(EE_MATRIXMULT_MISMATCH);
		return;
	}

	if (MCArraysCreateWithMatrix(*t_product, r_result))
		return;

	ctxt.Throw();
}
Example #2
0
void MCMailDoComposeMail(MCExecContext& ctxt, MCStringRef p_to, MCStringRef p_cc, MCStringRef p_bcc, MCStringRef p_subject, MCStringRef p_body, MCArrayRef p_attachments, MCMailType p_type)
{	
	bool t_can_send;
	MCMailGetCanSendMail(ctxt, t_can_send);

	if (!t_can_send)
		return;

	MCAutoArray<MCAttachmentData> t_attachments;

	if (p_attachments != nil && !MCArrayIsEmpty(p_attachments))
	{
		MCValueRef t_data;
		MCValueRef t_file;
		MCValueRef t_type;
		MCValueRef t_name;
		MCAttachmentData t_attachment;
		
		if (MCArrayIsSequence(p_attachments))
		{
			for(uindex_t i = 0; i < MCArrayGetCount(p_attachments); i++)
			{
				MCValueRef t_value;
				MCArrayFetchValueAtIndex(p_attachments, i + 1, t_value);
				if (!MCValueIsArray(t_value))
					continue;

                if (!MCArrayFetchValue((MCArrayRef)t_value, false, MCNAME("data"), t_data) ||
                    !ctxt . ConvertToData(t_data, t_attachment . data))
                    t_attachment . data = nil;
                
                if (!MCArrayFetchValue((MCArrayRef)t_value, false, MCNAME("file"), t_file) ||
                    !ctxt . ConvertToString(t_file, t_attachment . file))
                    t_attachment . file = nil;
                
                if (!MCArrayFetchValue((MCArrayRef)t_value, false, MCNAME("type"), t_type) ||
                    !ctxt . ConvertToString(t_type, t_attachment . type))
                    t_attachment . type = nil;
                
                if (!MCArrayFetchValue((MCArrayRef)t_value, false, MCNAME("name"), t_name) ||
                    !ctxt . ConvertToString(t_name, t_attachment . name))
                    t_attachment . name = nil;

				t_attachments . Push(t_attachment);
			}	
		}
		else
		{
			if (!MCArrayFetchValue(p_attachments, false, MCNAME("data"), t_data) ||
                !ctxt . ConvertToData(t_data, t_attachment . data))
                t_attachment . data = nil;
            
            if (!MCArrayFetchValue(p_attachments, false, MCNAME("file"), t_file) ||
                !ctxt . ConvertToString(t_file, t_attachment . file))
                t_attachment . file = nil;
            
            if (!MCArrayFetchValue(p_attachments, false, MCNAME("type"), t_type) ||
                !ctxt . ConvertToString(t_type, t_attachment . type))
                t_attachment . type = nil;
            
            if (!MCArrayFetchValue(p_attachments, false, MCNAME("name"), t_name) ||
                !ctxt . ConvertToString(t_name, t_attachment . name))
                t_attachment . name = nil;
		
			t_attachments . Push(t_attachment);
		}
	}

	MCAutoStringRef t_result;

	MCSystemSendMailWithAttachments(p_to, p_cc, p_bcc, p_subject, p_body, p_type, t_attachments . Ptr(), t_attachments . Size(), &t_result);

	ctxt . SetTheResultToValue(*t_result);
}