Skip to main content
Version: v6.7.0

For Each value...Next

Command Description​

Sequentially obtain (also known as traverse) each element in an array or dictionary, and execute the following block of statements separately for the value of each obtained element.

Command Prototype​

For Each value In dataStruct

Next

Parameter Description​

ParameterRequiredTypeDefaultDescription
valueTrueidvalueTraverse value
dataStructTrueexpressionarrayRetThe data structure to be traversed

Demo​

TracePrint("------------------------------------ Traverse the array--------- ----------------------------------") 
//-------------------------------------------------------------------------------
//[Remarks] Loop through each piece of data in Collection , substitute the name of the data (when corresponding to a dictionary) or index (when corresponding to an array) into key, substitute the value of the data into value and execute the Block statement block .
TracePrint("Let the array a = ['U','i','B','o','T'], traverse and print each value")
a = ['U','i','B','o','T']
For Each value In a
TracePrint value
Next