op_vvec_value_get()

Abstract

Copies a value within a value vector to a specified variable.

Syntax

op_vvec_value_get (source, position, value_ptr)
Argument Type Description
source Vvec_Vector value vector from which to retrieve the value
position unsigned int index number of the value to be retrieved
value_ptr void * pointer to the variable that will hold the value retrieved

Return Type

Compcode

Completion code indicating success or failure in getting the value.

This procedure returns OPC_COMPCODE_SUCCESS if the value was successfully retrieved. It returns OPC_COMPCODE_FAILURE if it could not retrieve the value. Failure might occur, for example, if position is past the end of the vector.

Example

/* Run through an integer vector and calculate a sum of all of its components. */

sum = 0;
for (i = 0; i < op_vvec_size_get (target_vector); i++)
	{
	/* get current value.	*/
	op_vvec_value_get (target_vector, i, &val);

	sum = sum + val;
	}

/* sum now contains the summation over the value vector. */

Details

For value vectors of type OpC_Type_Boolean or OpC_Type_Bit, this function returns one of the following constants:

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

Purpose

Provide a mechanism to read single elements from value vectors.

Errors

  • Recoverable Error: Value vector is invalid.
  • Recoverable Error: Position (<pos>) exceeds element count of value vector.
  • Recoverable Error: Destination value pointer is invalid.

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