Store values of for each

Hi !

can you help me how to store the values that are running inside aech, if possible store all values in text

May we ask you to give us more details

  • on what are you looping within for each (e.g. List, Array, Datarow)
  • what is to store within the loop

Thanks for support

Use Assign like you normally would. The fact that it’s in a loop doesn’t change anything, it just means the Assign will be processed each time through the loop. Just make sure the variable you’re assigning the value to isn’t scoped to just the For Each.

If you’re unfamiliar with variable scoping, it is very important. This is Javascript, but the scope concept is the same.


Esse for each me retorna todos os valores desse Directory; > Directory.GetFiles("C:\Users\luan.carvalho\OneDrive - Solistica\Escritorio\SIGMA CORTE","*" + "*.XML")

the intent and store these values.

Store them for what use? Just one big string? Individual values, maybe an array?

If you want to write back to excel you can use “Add to datarow” activity inside the loop. Outside the loop write to values to the excel using write range activity.

If you want to store it in an array or list, use “Add to collection” activity inside the loop.

Hope this helps…

I have a for-aech that copies files from one for each data table to aech > Directory.GetFiles (“C: \ Users \ luan.oak \ OneDrive - Solistica \ Office \ MERCK SACORTE \ BASE XML”, “" + Row .Item (“DANFE”). ToString + ".xml”), but since it’s in loop, it doesn’t return the false value, the idea that it’s for-aech returns the values that were copied and compares the information

What false value? All your code is doing is grabbing a list of files in a folder and looping through them. What are you going to do with these values?

I want to have these values in excel or notepad

@Luan_Carvalho_Da_Conceica - friend…I am not sure what is the exact requirement?

I have that in mind…

but this error occurs.
Add Data Row: Object reference not set to an instance of an object.

Please show us the screenshot for the Add Data Row properties…Have you created a build data table or using the datatable from the read range output?

assign; str_input> Directory.GetFiles(“C:\Users\luan.carvalho\OneDrive - Solistica\Escritorio\SIGMA CORTE”,“" + ".XML”).ToArray

for aech > typeArgument Object

image

image

Good Morning !
I solved the problem, the activity will find all the xmls files and will return the name in an excel spreadsheet, creating a log

thank you all !!

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.