![background image](http://html1.mh-extra.com/html/advantech/ubiq/ubiq_user-manual_2856809059.webp)
53
UbiQ Scenario Manager User Manual
Chapter 4
B
asic of
Smart-C
S
cript
Language
}
return(running_sum);
}
In this example, the main function calls one function: sum. The sum function returns
the sum from 1 to num, where the return value is assigned to nSum.
while statement
The while statement lets you repeat a statement until a specified expression
becomes false.
Syntax
while-statement :
while ( expression ) block-statement
The expression must have arithmetic type. Execution proceeds as follows:
* The expression is evaluated.
* If expression is initially false, the body of the while statement is never executed, and
control passes from the while statement to the next statement in the program. If
expression is true (nonzero), the body of the statement is executed and the process
is repeated beginning at step 1.
The while statement can also terminate when a break, or return within the statement
body is executed. Use the continue statement to terminate an iteration without exiting
the while loop. The continue statement passes control to the next iteration of the
while statement.
This is an example of the while statement:
while(num>0) {
running_sum = runni num;
num = num - 1;
}
This example adds running_sum from 1 to num. If num is greater than 0,
running_sum added by num. When num reaches 0, execution of the while statement
terminates.
Functions
The function is the fundamental modular unit in C. A function is usually designed to
perform a specific task, and its name often reflects that task. A function contains dec-
larations and statements. This section describes how to declare, define, and call C
functions. Other topics discussed are:
* Overview of functions
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...