[ERROR] Cannot read properties of undefined (reading 'source_array')

I’ve been getting this error since I installed the updated version of Studio Pro (9.0.4).

I have a main.neek file with loops that call various subprograms. These subprograms also have loops inside of them, more specifically For Each Row activities that loop through an Excel file with a few sheets. This is an example of the situation that generates the error:

The main program

The subprogram

Global variables exported from the main program to the subprogram:

  • excelContent
  • listOfSheets
  • sheetIndex
  • loop

Variables imported from the subprogram to the main program:

  • verifierSub (subprogram) → verifier (main program)

Basically, the main program calls the subprogram inside a loop. The subprogram then executes actions inside a For Each Row loop of its own. The verifier variable determines what message is shown in the Console Log activities.

When the data in line 2 from the Excel sheet is “—” that means the robot should go to the next sheet. That is signaled byverifier=2. So the robot exits the subprogram, goes back to the main program, increments some variables to access the next sheet in the Excel file, and enters the subprogram again. When the data in line 2 of the Excel sheet is different from “—”, that signals the robot that it must remain in the For Each Row loop until it runs through every line in the sheet that contains data. In this caso verifier = 0, so the robot keeps running For Each Row loop in the subprogram withut interruption. After it finishes, it eits the subprogram, incrments the varibles in the main program to access the next sheet, and so on and so forth.

Well, that being said, the problem is that the robot executes normally the first time it goes through the For Each Row activity, but it stops the second time and the console shows the error.

If I put everything in the same program (just one file, no subprogram), it works. But if I try to divide into subprograms, the For Each Row activity always stops the second time through and the console throws the aforementioned error.

I don’t want to put everything in the same file, it’s too messy. Dividig everything into subprograms makes things easier to organize. Has anybody else experienced a similar problem? Is there a solution to this?

1 Like

Hi @cris-dsc, Could you please open a ticket with support in the support center for further assistance and analysis?

I’ve already done that and the person taking care of the ticket is still trying to understand the problem and find a solution. I posted about it here to see if more people have experienced the problem and/or has a solution.

2 Likes

Hello @cris-dsc Thank you for the clarification.

1 Like

So, after a meeting with someone from the support team and running a few tests, we solved the problem. The last activity in the For Each Row needs to be connected to the Loop end dot. Also, the variables imported from the subprogram must be called in the Calculate a value option in the Assign value to variable properties in the main program, so they must be set as global variables.

I followed the instructions from the Help Center article “Variable Scope”, so I used Save value to variable instead of calculating a value. Anyway, the issue has been resolved and my program works now.

2 Likes