How to create an array?
We can create an array using the command ‘set’. For example, set a[0] = 1 means we created an array whose first element of index 0 has a value of 1. Also, another way to define an array is by creating a list and then looping through it. Let us look at the below example.
@echo off set list_1=7 9 1 3 (for %%p in (%list_1%) do ( echo %%p ))
The above command produces the below output
7 9 1 3
Batch Script – Arrays
An array is a collection of elements of the same data type. The arrays are not explicitly defined as Batch Script types but can be used. The following items need to be noted when the same members are used in Batch Script.
- Each aspect of the same members needs to be defined by a set order.
- A ‘for’ loop will be required to double the program values.
Contact Us