RobotStudio event

The type or namespace name 'Modules' could not be found

Hello, I trying this example from flexpendan sdk, And I got this error while trying to compile:
Error    1    The type or namespace name 'Modules' could not be found (are you missing a using directive or an assembly reference?)    C:\Users\W7\Documents\Visual Studio 2008\Projects\TpsViewIRC5WartsilaApp\TpsViewIRC5WartsilaApp\view.cs    184    18    TpsViewIRC5WartsilaApp

This is the exampled extracted from SDK help

private int CountRoutines(Controller c)
{
    int result = 0;
    Task[] tasks;
    try
    {
        tasks = c.Rapid.GetTasks();

        Modules modules;

        // Iterate tasks
        foreach (Task t in tasks)
        {
            // Get all modules of the task
            modules = t.GetModules();

            Routines routines;                
            foreach (Module m in modules)
            {
                // Get all routines of the module
                routines = m.GetRoutines();

                result += routines.Lenght;
            }
        }
    }
    catch (GeneralException ee)
    {
        // TODO: Add error handling
    }
    catch (System.Exception ee)
    {
        // TODO: Add error handling
    }

    return result;
}

Any Idea?
Thanks for help


Jorge Turiel

Answers

  • Hi Jorge, the data types Modules and Routines don't exist.
    The methods getRoutines and getModules return an array. 
    Here is the correct code.

     private int CountRoutines(Controller c)
            {
                int result = 0;
                Task[] tasks;
                try
                {
                    tasks = c.Rapid.GetTasks();

                    Module[] modules;

                    // Iterate tasks
                    foreach (Task t in tasks)
                    {
                        // Get all modules of the task
                        modules = t.GetModules();

                        Routine[] routines;
                        foreach (Module m in modules)
                        {
                            // Get all routines of the module
                            routines = m.GetRoutines();
                            result += routines.Length;
                        }
                    }
                }
                catch (GeneralException ee)
                {
                    // TODO: Add error handling
                }
                catch (System.Exception ee)
                {
                    // TODO: Add error handling
                }

                return result;
            }

    Best regards,
    //U.
  • Thanks for your help, It's works
    /J
    Jorge Turiel