RobotStudio event

Use of arrays as parameters and as RECORD elements

Options
Hi,

I'm looking to do some fairly extensive manipulation of arrays in RAPID, and it would be a whole lot tidier if I could do things such as:

    Passing an array as a parameter to a Proc/Func;
    Declare an array as part of a RECORD or
    Redimension an existing array, i.e. change its size.

Can't find anything in the RAPID manual on the subject, and running possible syntax through the syntax checker has only given negative results.

Any thoughts?

Andrew

Comments

  • RussD
    Options
    Passing an array as a parameter to a Proc/Func;
     

    Yes you can do this:

     

    PROC myTest(num myNum{*})

        !do something

    ENDPROC

     

    Declare an array as part of a RECORD

     

    No, but the record can consist of other record types that could represent an array-like type:

     

    RECORD comp1

        num n1;

        num n2;

        num n3;

    ENDRECORD

     

    RECORD myRec

        comp1 c1;

        bool bBool;

    ENDRECORD

     

    You could probably come up with some method using late-binding to fill in the elements of comp1 using a loop.


    Redimension an existing array, i.e. change its size.

     

    I don't think this is possible


     
    Russell Drown
  • Thanks for that - the paragraph on sending a parameter looks useful, I hadn't tried putting a star in the curly brackets!

    One more thing - can I use an array as a return value from a func?
    Andrew
  • RussD
    Options
    Unfortunately, this is not possible, as described in section 5.4 of the RAPID Kernel reference:
    Functions can have (return) any value data type (including any available installed type). A function cannot be dimensioned, i.e. a function cannot return an array value.
    Russell Drown

  • [QUOTE=Cypherspaceman]One more thing - can I use an array as a return value from a func?
    [/QUOTE]You can pass the array as an INOUT parameter to the func. That way you can still modify it.