About CPL Functions

<< Click to Display Table of Contents >>

Navigation:  Concordance Programming Fundamentals > Writing a Function >

About CPL Functions

In CPL, a function is a re-usable procedure within an application. Functions exist because, very often, you may need to perform certain tasks multiple times. Or, they exist because they can act as reasonable abstractions for certain tasks.

The following script declares and uses the Multiply_X_by_Y CPL function, which will be analyzed in the following topics:

main()

{

   int myValue;

   int valOne;

   int valTwo;

 

   valOne = 10;

   valTwo = 5;

 

   myValue = Multiply_X_by_Y(valOne, valTwo);

}

 

Multiply_X_by_Y(int x, int y)

{

   int z;

   z = x * y;

   return(z);
}

Topic

Description

About the Main() Function

Discussion of how the main() function starts off the entire CPL script.

Beginning and Ending a Function

How to begin and end a function.

Declaring Variables

How to declare and use variables in a function.

Writing a Function Body

How to write a function.

Returning a Value

How to return a value from a function call.

Calling a Function

How to call a function from another function, such as main().

About Built-in functions

Discusses the built-in CPL functions.