Академический Документы
Профессиональный Документы
Культура Документы
file:///C:/Users/gilbertojunior/AppData/Local/Temp/~hh7A06.htm 25/03/2019
Using Cicode Functions Page 2 of 5
where:
FunctionName is the name of the function
Arg1, Arg2, ... are the arguments you pass to the function
Cicode Programming Reference > Using Cicode Functions > Triggering Functions via Runtime Operator Input
Command PageNext();
Cicode Programming Reference > Using Cicode Functions > Evaluating Functions
Evaluating Functions
You can use a function in any expression. For example, the AlarmActive() function returns TRUE (1) if any
alarms are active, and FALSE (0) if no alarms are active. In the following text object, either ʺAlarms Activeʺ or
ʺNo Alarms Activeʺ is displayed, depending on the return value of the expression.
Note: Functions return a value that indicates the success of the function, or provides information on an
error that has occurred. In many cases (for example, when used in a command) the return value can be
ignored. You need to use the parentheses () in the function name, even if the function uses no arguments.
Function names are not case-sensitive: PageNext(), pagenext() and PAGENEXT() call the same function.
Cicode Programming Reference > Using Cicode Functions > Combining Functions with Other Statements
file:///C:/Users/gilbertojunior/AppData/Local/Temp/~hh7A06.htm 25/03/2019
Using Cicode Functions Page 3 of 5
Each statement is executed in order. The ʺShiftʺ report is started first, the variable B1_TIC_101_PV is set to 10
next, and finally, the ʺBoiler 1ʺ page is displayed.
Functions combine with operators and conditional executors to give you specific control over your processes,
for example, you can test for abnormal operating conditions and act on them.
Cicode Programming Reference > Using Cicode Functions > Passing Data to Functions (Arguments)
Note: Some functions (such as PageNext()) have no arguments. However you need to include the
parentheses ( ) or Vijeo Citect will not recognize that it is a function, and an error could result when the
project is compiled.
Cicode Programming Reference > Using Cicode Functions > Using String Arguments
This function displays the graphics page called ʺBoiler 1ʺ. Be aware that when you pass a string to a function,
you need to always enclose the string in double quotes.
You can use the PageDisplay() function to display any graphics page in your system - in each case, only the
argument changes. For example, the following command displays the graphics page ʺBoiler 2ʺ:
You can use the Report() function to run a report (for example, the ʺShiftʺ report) when the command
executes:
Command Report("Shift");
The following example uses the Prompt() function to display the message ʺPress F1 for Helpʺ on the screen
when the command executes:
String assignment
You can also assign string variables in commands. For example, if BATCH_NAME is a variable tag defined as
a string data type, you can use the following command to set the tag to the value ʺBreadʺ:
BATCH_NAME = "Bread";
Cicode Programming Reference > Using Cicode Functions > Using the Caret Escape Sequence Character
file:///C:/Users/gilbertojunior/AppData/Local/Temp/~hh7A06.htm 25/03/2019
Using Cicode Functions Page 4 of 5
the formatting of text strings. Escape sequences include formatting instructions such as new line, form feed,
carriage return, backspace, horizontal and vertical tab-spaces, single and double quote characters, the caret
character, and hexadecimal numbers.
Strings are commonly represented in Cicode between double quote characters ( ʺ ) known as delimiters. If you
want the string to contain a double quote character itself as part of the string, you need to precede the double
quote character with the caret character ( ^ʺ ) so that Cicode doesnʹt interpret the double quote in the string as
the delimiter indicating the end of the string. The caret character is interpreted as a special instruction, and
together with the characters immediately following it, are treated as an escape sequence instruction. See the
section titled Formatting Text Strings for the list of escape sequences used in Cicode.
In the following Cicode example, both of these message functions will display the following message.
Cicode Programming Reference > Using Cicode Functions > Using Multiple Arguments
The order of the arguments affects the operation of any function. The Login() function logs a user into your
runtime system. The first argument ( ʺManagerʺ ) indicates the name of the user, and the second argument
( ʺABCʺ ) is the userʹs password. If you reverse the order of the arguments, the function would attempt to
login a user called ʺABCʺ - if a user by this name does not exist, an error message displays.
Cicode Programming Reference > Using Cicode Functions > Using Numeric Arguments
In this instance, the value of B1_TIC_101_PV displays. If it is a real-time variable, the number that displays
depends on its value at the time.
Note: If you use double quotes around variables, for example, ʺB1_TIC_101_PVʺ, the text string
B1_TIC_101_PV displays, rather than the value of the variable.
Cicode Programming Reference > Using Cicode Functions > Using Operator Input in Functions
file:///C:/Users/gilbertojunior/AppData/Local/Temp/~hh7A06.htm 25/03/2019
Using Cicode Functions Page 5 of 5
Command PageDisplay(Arg1);
When the command executes, the page name is passed to the function as Arg1. The operator can then display
any page, for example:
Cicode Programming Reference > Using Cicode Functions > Returning Data from Functions
The following example shows an entry command event for a graphics page, using a combination of two
functions. The FullName() function returns the name of the user who is currently logged in to the run-time
system, passing this name to the calling function, Prompt(). When the page is opened, a welcome message
displays in the prompt line.
For example, if the current user is John Citizen, the message ʺHello, John Citizenʺ displays.
file:///C:/Users/gilbertojunior/AppData/Local/Temp/~hh7A06.htm 25/03/2019