Click or drag to resize

TaskSearchRapidSymbol Method

General RapidSymbol search method. Searches the task for symbols that match the specified criteria.

Namespace:  ABB.Robotics.Controllers.RapidDomain
Assembly:  ABB.Robotics.Controllers (in ABB.Robotics.Controllers.dll) Version: 6.5.129.0
Syntax
C#
public override RapidSymbol[] SearchRapidSymbol(
	RapidSymbolSearchProperties sProps,
	string stDataType,
	string stRegex
)

Parameters

sProps
Type: ABB.Robotics.Controllers.RapidDomainRapidSymbolSearchProperties
Instance of RapidSymbolSearchProperties ,which defines the search criteria.
stDataType
Type: SystemString
Name of the datatype to search for. Use string.Empty if not of interest.
stRegex
Type: SystemString
The regular expression to search for. Use string.Empty if not of interest.

Return Value

Type: RapidSymbol
An array of RapidSymbol. If none is found an array of length zero is returned.
Exceptions
ExceptionCondition
GeneralExceptionA General Exception has occurred.
Remarks
To search data declared in System scope, e.g. Shared data, set RapidSymbolSearchProperties.SearchMethod to SymbolSearchMethod.Scope. See the second example below.

NOTE! RAPID data declared in a -Shared -Hidden module cannot be accessed.

Examples
This example lists all functions and RAPID data instances of type num declared in task T_ROB1. The name of RapidSymbol and the module where it is declared are added to a listview.
private void btnSearch_Click(object sender,EventArgs e)
   {
       try
       {
           // Create Task if not done
           if (tT_Rob1 == null)
               tT_Rob1 = ctrl.Rapid.GetTask("T_ROB1");

           RapidSymbolSearchProperties sProp = 
           RapidSymbolSearchProperties.CreateDefault();
           sProp.SymbolType = SymbolTypes.Function | SymbolTypes.RapidData;
           sProp.IsInUse = false;
           sProp.SearchMethod = SymbolSearchMethod.Block;

           RapidSymbol[] datas = tT_Rob1.SearchRapidSymbol(sProp,"num",string.Empty);

           foreach (RapidSymbol rs in datas)
           {
               ListViewItem li = new ListViewItem(rs.Name);

               // [<TASK>,<MODULE>,...]
               li.SubItems.Add(rs.Scope[1]);

               // Add item
               listView1.Items.Add(li);
           }
       }
       catch (System.Exception ee)
       {
           // Handle any error here
       }
   }

This example shows a simple search method that find declared data of type defined by parameter sDataType. Parameter bSystem determines the scope to search. The search is made from task T_ROB1.

private RapidSymbol[] GetSymbols(string stDataType, bool bSystem)
{
    RapidSymbol[] result = new RapidSymbol[0];
    Task tRob1 = null;
    try
    {
        // Create temporary controller object to get task
        using (Controller c = new Controller())
        {
            tRob1 = c.Rapid.GetTask("T_ROB1");

            if (tRob1 != null)
            {
                RapidSymbolSearchProperties sProps = RapidSymbolSearchProperties.CreateDefault();

                // Setup sProps according to parameter bSystem
                if (bSystem == true)
                {
                    // Search data that the task can se in System scope, e.g. Shared data
                    sProps.GlobalRapidSymbol = true;
                    sProps.IsInUse = false;
                    sProps.LocalRapidSymbol = false;
                    sProps.Recursive = false;
                    sProps.SearchMethod = SymbolSearchMethod.Scope;
                    sProps.SymbolType = SymbolTypes.RapidData;
                }
                else
                {
                    // Search Task scope
                    sProps.SymbolType = SymbolTypes.RapidData;
                    sProps.IsInUse = false;
                    sProps.SearchMethod = SymbolSearchMethod.Block;
                }

                // Perform the search
                result = tRob1.SearchRapidSymbol(sProps, stDataType, string.Empty);
            }
            else
            {
                // No task to search from
            }
        }
    }
    catch (GeneralException ge)
    {
        // TODO: Add error handling
    }
    catch (System.Exception se)
    {
        // TODO: Add error handling
    }
    finally
    {
        // Release temporary resources
        if (tRob1 != null)
        {
            tRob1.Dispose();
            tRob1 = null;
        }
    }
    return result;
}
See Also