RobotStudio event

Reading and Writing array of Rapid

Options
Hi,
   How can I read and modify the array of  Rapid in VB.net.  My reading array program as folllows: 

 Dim RD As RapidData = Me.controller.Rapid.GetRapidData("T_ROB1", "MainModule", "array1")
        If RD.IsArray Then
            Dim AD As ArrayData = DirectCast(RD.Value, RapidDomain.ArrayData)
            Dim ASum As Double = 0.0R
            Dim ANum As RapidDomain.Num
            For I As Integer = 1 To AD.Length
                ANum = DirectCast(AD(I - 1), Num)
                ASum += DirectCast(ANum.Value, Double)
            Next
            ANum = DirectCast(RD.ReadItem(1, 1), Num)

    I define the array in Rapid as "PERS num array1{2}:=[50,60];"

    The program can not work , the error is "An argument specified by the client is not valid for this type of operation."  to the instruction "ANum = DirectCast(RD.ReadItem(1, 1), Num)"

    How Can I do?  Thanks everyone

Comments

  • RussD
    Options
    Shouldn't you use ReadItem(i) instead?
     

    You only have a 1-d array, also I think a RapidData object will be 0-based, while the RAPID ArrayData would be 1-based.
    Russell Drown