op_vvec_value_set()

Abstract

Assign a value to a specific element in a value vector.

Syntax

op_vvec_value_set (target, position, value)
Argument Type Description
target Vvec_Vector value vector to be modified
position unsigned int index number of the value to be set
value Vartype value to place into the vector at position

Return Type

Compcode

Completion code indicating success or failure in setting the value.

The procedure returns OPC_COMPCODE_SUCCESS if the value was successfully set. It returns OPC_COMPCODE_FAILURE if it could not set the value. Failure might occur, for example, if there is insufficient memory to expand the vector.

Example

/* Run through a STDLOGIC value vector and change all occurrences of 'Z' to '0'. */
for (i = 0; i < op_vvec_size (target_vector); i++)
	{
	/* get current value. */
	op_vvec_value_get (target_vector, i, &val);

	/* test for equality. */
	if (val == 'Z')
		{
		op_vvec_value_set (target_vector, i, '0');
		}
	}

Details

For value vectors of type OpC_Type_Boolean or OpC_Type_Bit, do not assign the literal values 0 and 1. Instead, use the corresponding constants:

  • OpC_Bool_F and OpC_Bool_T for boolean
  • OpC_Bit_0 and OpC_Bit_1 for bit

If the vector element specified by position is past the end of the vector, op_vvec_value_set() expands the vector, creating the new position and all elements needed to increase the vector to the new size. Unspecified values are set to the following defaults:

Table 23: op_vvec_value_set() Default Values by Type

Value Type Default
integer 0
double 0.0
pointer OPC_NULL (for pointers)
char \0' (for char)
bit OPC_BIT_0
standard logic “0”
boolean OPC_BOOL_F

Purpose

Provide a mechanism to assign values to individual elements within existing value vectors.

Errors

  • Recoverable Error: Value vector is invalid.
  • Recoverable Error: Insufficient memory to set value at position (<pos>).

Reference

本站文档由 北京智网畅联科技有限公司 整理、翻译并提供 · Documentation compiled and provided by Beijing ZNetLink Technology Co., Ltd.

交流群 · QQ Group:OPNET/智网妙算网络仿真交流群(群号 486383494)

原文档 © 2017 Riverbed Technology · 本站为公益翻译,由 AI 辅助完成,请仔细甄别

Original documentation © 2017 Riverbed Technology. Community translation, AI-assisted. Contact: jiazequn@znetlink.com