示例#1
0
static DSC *execute_edit( qli_nod* node)
{
/**************************************
 *
 *	e x e c u t e _ e d i t
 *
 **************************************
 *
 * Functional description
 *	Edit a blob.  If there's an existing
 *	blob for input, force the descriptor
 *	to quad to get move the id.
 *
 **************************************/
	qli_dbb* dbb = (qli_dbb*) node->nod_arg[e_edt_dbb];
	ISC_QUAD* id = (ISC_QUAD*) & node->nod_arg[e_edt_id1];

	dsc* desc = NULL;

	if (node->nod_arg[e_edt_input])
	{
		desc = EVAL_value(node->nod_arg[e_edt_input]);
		if (desc && (desc->dsc_dtype == dtype_blob))
		{
			desc->dsc_dtype = dtype_quad;
			MOVQ_move(desc, &node->nod_desc);
			desc->dsc_dtype = dtype_blob;
		}
	}
	if (!desc)
		id->gds_quad_low = id->gds_quad_high = 0;

	const TEXT* field_name = (TEXT*) node->nod_arg[e_edt_name];
	BLOB_edit(id, dbb->dbb_handle, dbb->dbb_transaction, field_name);

	node->nod_desc.dsc_missing = UserBlob::blobIsNull(*id) ? DSC_missing : 0;

	return &node->nod_desc;
}
示例#2
0
void EVAL_break_increment( qli_nod* node)
{
/**************************************
 *
 *	E V A L _ b r e a k _ i n c r e m e n t
 *
 **************************************
 *
 * Functional description
 *	Initialize a report-local statistical function.
 *
 **************************************/
	DSC* desc1 = &node->nod_desc;

	// Knock off count as trivial

	if (node->nod_type == nod_rpt_count)
	{
		*(SLONG *) node->nod_desc.dsc_address += 1;
		return;
	}

	// Evaluate the sub-expression.  If null, don't bother to do anything
	// more.  If not, bump the number of records involved

	dsc* desc2 = EVAL_value(node->nod_arg[e_stt_value]);
	if (!desc2)
		return;

	// If this is the first value, just move it in.

	const SLONG count = (IPTR) node->nod_arg[e_stt_default] + 1;
	if (count == 1)
	{
		if (desc2->dsc_missing)
			desc1->dsc_missing = DSC_missing;
		else
		{
			desc1->dsc_missing = FALSE;
			MOVQ_move(desc2, desc1);
			node->nod_arg[e_stt_default] = (qli_nod*) (IPTR) count;
		}
		return;
	}
	if (desc2->dsc_missing)
		return;

	node->nod_arg[e_stt_default] = (qli_nod*) (IPTR) count;
	desc1->dsc_missing = FALSE;

	// Finish off as per operator

	SSHORT comparison;

	switch (node->nod_type)
	{
	case nod_rpt_min:
	case nod_rpt_max:
		if (!(comparison = MOVQ_compare(desc2, desc1)))
			break;
		if ((comparison > 0 && node->nod_type == nod_rpt_max) ||
			(comparison < 0 && node->nod_type == nod_rpt_min))
		{
			MOVQ_move(desc2, desc1);
		}
		break;

	case nod_rpt_total:
	case nod_rpt_average:
		if (desc1->dsc_dtype == dtype_long)
			*(SLONG *) desc1->dsc_address += MOVQ_get_long(desc2, desc1->dsc_scale);
		else
			*(double *) desc1->dsc_address += MOVQ_get_double(desc2);
		break;
	}
}
static void edit_date( const dsc* desc, pics* picture, TEXT** output)
{
/**************************************
 *
 *	e d i t _ d a t e
 *
 **************************************
 *
 * Functional description
 *	Edit data from a descriptor through an edit string to a running
 *	output pointer.
 *
 **************************************/
	SLONG date[2];
	DSC temp_desc;
	TEXT d, temp[256];

	temp_desc.dsc_dtype = dtype_timestamp;
	temp_desc.dsc_scale = 0;
	temp_desc.dsc_sub_type = 0;
	temp_desc.dsc_length = sizeof(date);
	temp_desc.dsc_address = (UCHAR*) date;
	QLI_validate_desc(temp_desc);
	MOVQ_move(desc, &temp_desc);

    tm times;
	isc_decode_date((ISC_QUAD*) date, &times);
	TEXT* p = temp;

	const TEXT* nmonth = p;
	p = cvt_to_ascii((SLONG) times.tm_mon + 1, p, picture->pic_nmonths);

	const TEXT* day = p;
	p = cvt_to_ascii((SLONG) times.tm_mday, p, picture->pic_days);

	const TEXT* year = p;
	p = cvt_to_ascii((SLONG) times.tm_year + 1900, p, picture->pic_years);

	const TEXT* julians = p;
	p = cvt_to_ascii((SLONG) times.tm_yday + 1, p, picture->pic_julians);

	const TEXT* meridian = "";
	if (picture->pic_meridian)
	{
		if (times.tm_hour >= 12)
		{
			meridian = "PM";
			if (times.tm_hour > 12)
				times.tm_hour -= 12;
		}
		else
			meridian = "AM";
	}

	const SLONG seconds = date[1] % (60 * PRECISION);

	TEXT* hours = p;
	p = cvt_to_ascii((SLONG) times.tm_hour, p, picture->pic_hours);
	p = cvt_to_ascii((SLONG) times.tm_min, --p, picture->pic_minutes);
	p = cvt_to_ascii((SLONG) seconds, --p, 6);

	if (*hours == '0')
		*hours = ' ';

	SLONG rel_day = (date[0] + 3) % 7;
	if (rel_day < 0)
		rel_day += 7;
	const TEXT* weekday = alpha_weekdays[rel_day];
	const TEXT* month = alpha_months[times.tm_mon];

	picture->pic_pointer = picture->pic_string;
	picture->pic_count = 0;
	TEXT* out = *output;

	bool sig_day = false;
	bool blank = true;

	for (;;)
	{
		TEXT c = generate(picture);
		if (!c || c == '?')
			break;
		c = UPPER(c);

		switch (c)
		{
		case 'Y':
			*out++ = *year++;
			break;

		case 'M':
			if (*month)
				*out++ = *month++;
			break;

		case 'N':
			*out++ = *nmonth++;
			break;

		case 'D':
			d = *day++;
			if (!sig_day && d == '0' && blank)
				*out++ = ' ';
			else
			{
				sig_day = true;
				*out++ = d;
			}
			break;

		case 'J':
			if (*julians)
				*out++ = *julians++;
			break;

		case 'W':
			if (*weekday)
				*out++ = *weekday++;
			break;

		case 'B':
			*out++ = ' ';
			break;

		case 'P':
			if (*meridian)
				*out++ = *meridian++;
			break;

		case 'T':
			if (*hours)
				*out++ = *hours++;
			break;

		case '"':
		case '\'':
		case '\\':
			literal(picture, c, &out);
			break;

		default:
			*out++ = c;
			break;
		}
		if (c != 'B')
			blank = false;
	}

	*output = out;
}