RobotStudio event

array syntax, loading modules and searching.

Options

Hi Everyone, I'm having a problem with syntax for searching for an array.

1)  I want to load a module in an order defined by an array:
CONST string Modules{4}:=["mod1.MOD","mod2.mod","mod3.mod","mod4.mod"];
      PROC Load_module()
        FOR i FROM 1 TO Dim(Modules,1) DO
            Load\Dynamic,diskhome\file:="Modules{i}";

 Within this module are a listing of RobTargets, and another array (called “Positions#” where # will change for each module) defining the position that I need the robot to work.  These are large – 2000 points and the array with 2000 names in it.

2)  Once that module is in memory, I want to search it to look for the array that contains the robtarget order:
SetDataSearch "robtarget"\Object:="positions.*"\INMOD:="mod{i}.mod"\GlobalSym;
        getDataVal "positions.*",targets;

This is the problem area – I want to assign “positions#” to another array name “targets” so that my main program can maintain a generic variable name. 
Would someone be able to help with the syntax?

thanks Darren

Comments

  • Micky
    Micky ✭✭✭
    Options

    Hi,

    as described in the section "Limitations" in the chapter "SetDatasearch" in the reference Manual it is not possible to search for Arrays.

    In this case you can only use the instruction GetDataVal and verify if the error ERR_SYM_ACCESS  is not raised, to know if array is available.

    To be able to read the Array you have to define another array defined with the same size as variable (VAR) and use this as Parameter for GetDataval instruction.

    e.g.

    FUNC bool ReadArray(num Index)

      VAR robtarget pArray{2000};

      GetDataVal "Positions"+ValtoToStr(Index),pArray;

      RETURN true;

    ERROR

      !Array not available

      IF ERRNO= ERR_SYM_ACCESS  RETURN FALSE;

    ENDPROC

     

     

     

  • DSRTM
    Options
    Hi Micky, Thanks for the reply.  I didn't have my notifications set to email when someone posted. 

    I'll have a look at what you're suggesting. it looks like it should work. 

    Thanks
    Darren

    Micky said:

    Hi,

    as described in the section "Limitations" in the chapter "SetDatasearch" in the reference Manual it is not possible to search for Arrays.

    In this case you can only use the instruction GetDataVal and verify if the error ERR_SYM_ACCESS  is not raised, to know if array is available.

    To be able to read the Array you have to define another array defined with the same size as variable (VAR) and use this as Parameter for GetDataval instruction.

    e.g.

    FUNC bool ReadArray(num Index)

      VAR robtarget pArray{2000};

      GetDataVal "Positions"+ValtoToStr(Index),pArray;

      RETURN true;

    ERROR

      !Array not available

      IF ERRNO= ERR_SYM_ACCESS  RETURN FALSE;

    ENDPROC