Important

   

This documentation space contains information about PATROL Agents when deployed in a TrueSight Operations Management environment. If you are a BMC Helix Operations Management user, see PATROL Agent 22.1 for BMC Helix Operations Management. Open link

va_arg()

Retrieve the next argument in a function's variable argument list

Note

The va_arg() function is used only within user-defined function() statements that specify a variable list of arguments in the function() definition.

Syntax

va_arg(va-list)

Parameter

ParameterDefinition

va-list

PSL list containing a variable number of arguments

Description

Th e va_arg() function returns the next argument from the variable-length list va-list. If there are no mo re arguments in va-list, t he va_arg() function returns the NULL string and sets the PSL variable errno = 69 (E_PSL_ERANGE). 

When used with the va_start() function, the va_arg() can read a variable argument list multiple times, using the va_start() function to reset the list after each reading. (The va_start() function always resets the variable argument list to return the first argument.)

Example

The following is an exam ple of the va_arg() functio n:

function summation(...) {
c = sum = 0;
terms = va_start();
c = va_arg(terms);
while (c != "") {
sum += c;
c = va_arg(terms);
}
return sum;
}
function main() {
print("Sum of the first 2 numbers is : ",summation(1,2),"\n");
print("Sum of the first 3 numbers is : ",summation(1,2,3),"\n");
print("Sum of the first 4 numbers is : ",summation(1,2,3,4),"\n");
print("Sum of the first 5 numbers is : ",summation(1,2,3,4,5),"\n");
print("Sum of the first 6 numbers is : ",summation(1,2,3,4,5,6),"\n");
print("Sum of the first 7 numbers is : ",summation(1,2,3,4,5,6,7),"\n");
print("Sum of the first 8 numbers is : ",summation(1,2,3,4,5,6,7,8),"\n");
print("Sum of the first 9 numbers is : ",summation(1,2,3,4,5,6,7,8,9),"\n");
return;
}

The example produces the following output:

Sum of the first 2 numbers is : 3.000000
Sum of the first 3 numbers is : 6.000000
Sum of the first 4 numbers is : 10.000000
Sum of the first 5 numbers is : 15.000000
Sum of the first 6 numbers is : 21.000000
Sum of the first 7 numbers is : 28.000000
Sum of the first 8 numbers is : 36.000000
Sum of the first 9 numbers is : 45.000000

Was this page helpful? Yes No Submitting... Thank you

Comments