Extended Function Parameters Info

Extended Function Parameters Info

In WinCC OA, parameters are an essential concept for passing and modifying data within functions and methods. Understanding how to work with parameters is crucial for effective scripting and logic implementation.

Function Parameters

When you define a function in WinCC OA, you can specify one or more parameters. These parameters determine the input values that the function expects. You can pass different types of data, including structures and primitive types, as parameters to functions.

Passing a Structure as a Parameter

Structures are user-defined data types that can be passed as parameters to functions. Here's an example of passing a structure as a parameter:

    struct ScenarioDetails {
        string name;
        bool stationStartStatus;
        bool stationEndStatus;
        int progress;
        string color;
        string status;

    public string GetColor(ScenarioDetails scenarioDetails) {
        // Function logic here

Reference Parameters

WinCC OA allows you to use reference parameters to modify variables directly within a function. By using the ampersand (&) symbol, you can indicate that a parameter should be treated as a reference. This means any changes made to the parameter inside the function will affect the original variable.

    public void GetScenarioProgress(string ScenarioPassed, int& ScenarioParsedProgress) {
        // Function logic here

Optional Parameters

WinCC OA also supports optional parameters, allowing you to define functions with default values for some parameters. This can make your functions more flexible. Here's an example:

    public void MyFunc(int a, string b = "Default") {
        // Function logic here

Best Practices for Handling Parameters

While working with parameters in WinCC OA, it's essential to follow best practices to ensure clean and maintainable code. Here are some tips for handling parameters effectively:

  1. Use Descriptive Names: Give your parameters meaningful names that indicate their purpose. This makes your code more readable and understandable.
  2. Document Your Parameters: Include comments or documentation to explain the purpose of each parameter, its data type, and any constraints or expectations.
  3. Avoid Excessive Parameters: Limit the number of parameters in your functions to keep them concise and focused. Consider grouping related data into structures when necessary.
  4. Use Reference Parameters Sparingly: While reference parameters can be powerful, use them judiciously. Overuse of reference parameters can lead to complex code that is hard to maintain.
  5. Validate Inputs: Check and validate input parameters to ensure they meet the expected criteria. Proper input validation helps prevent errors and unexpected behavior. Many datatypes already have this such as isEmpty() or isDpTypeStruct()
  6. Consistency Matters: Maintain a consistent parameter naming and ordering convention throughout your codebase to enhance code readability.
  7. Test Thoroughly: Write test cases to verify that your functions handle parameters correctly under various scenarios. Testing helps catch and prevent issues early. you can use Exception Handling in many ways to thorw errors or just DebugN statements

By following these best practices, you can create well-structured functions and methods that are easy to understand, maintain, and debug.


While you can pass a variety of data types as parameters, there are some limitations. For example, you cannot pass a va_start or va_list parameter, and certain complex types like shared_ptr may not be passed directly as function parameters.


Understanding how to work with parameters, including reference parameters and optional parameters, is crucial for efficient scripting and logic development in WinCC OA. By leveraging these concepts, you can build powerful and flexible functions to meet your project's requirements.