![Advantech UbiQ User Manual Download Page 61](http://html1.mh-extra.com/html/advantech/ubiq/ubiq_user-manual_2856809061.webp)
55
UbiQ Scenario Manager User Manual
Chapter 4
B
asic of
Smart-C
S
cript
Language
In a function call, expression-list is a list of expressions (separated by commas). The
values of these latter expressions are the arguments passed to the function. If the
function takes no arguments, expression-list should contain the keyword void.
An argument can be any value with fundamental type. All arguments are passed by
value. This means a copy of the argument is assigned to the corresponding parame-
ter. The function does not know the actual memory location of the argument passed.
The function uses this copy without affecting the variable from which it was originally
derived.
The expression-list in a function call is evaluated and the usual arithmetic conver-
sions are performed on each argument in the function call. If a prototype is available,
the resulting argument type is compared to the prototype°Øs corresponding parame-
ter. If they do not match, either a conversion is performed, or a diagnostic message is
issued.
The number of expressions in expression-list must match the number of parameters,
unless the function°Øs prototype or definition explicitly specifies a variable number of
arguments. In this case, the interpreter checks as many arguments as there are type
names in the list of parameters and converts them, if necessary, as described above.
If the prototype°Øs parameter list contains only the keyword void, the interpreter
expects zero arguments in the function call and zero parameters in the definition. A
diagnostic message is issued if it finds any arguments.
The following examples illustrate the function argument.
int main()
{
int nSum;
nSum=sum(100);
printf(°×The sum(100)=%d°±,nSum);
}
/* Sum the values between 0 and num. */
sum(int num)
{
int running_sum;
running_sum = 0;
while(num>0) {
running_sum = runni num;
num = num - 1;
}
return(running_sum);
}
In this example, the sum function is declared in main to have one argument, repre-
sented by the identifier num, is an int values.
Summary of Contents for UbiQ
Page 1: ...User Manual UbiQ Scenario Manager User Manual V1 03...
Page 4: ...UbiQ Scenario Manager User Manual iv...
Page 7: ...Chapter 1 1 Introduction...
Page 13: ...Chapter 2 2 Getting Started...
Page 37: ...Chapter 3 3 Tutorials...
Page 47: ...Chapter 4 4 Basic of Smart C Script Language...
Page 62: ...UbiQ Scenario Manager User Manual 56...