I have written a Windows batch script to create an array and tried to print every element of the array.

However, the output is **`ECHO is off.`** instead of the actual value such as `"Apple"`.

When I changed **`ECHO is off.`** to **`@echo on`**, the result has just changed to **`ECHO is on`.**

```
@echo off

Rem Create variable
set fruit[0]="apple"
set fruit[1]="orange"
set fruit[2]="pear"
set fruit[3]="lemon"

REM x is the last index of the array
set x=3

REM for loop [with 0 for start, 1 for step, x for end]
FOR /L %%a in (0,1,%x%) DO (
   call set var=%%fruit[%%a]%%
   set var
   echo %var%
   call echo "Text2" 
  )

pause
```

The command **`call set var=%%fruit[%%a]%%`** is correct because when the command **`set var`** is run, the output can successfully show something like **`var="lemon"`**, which means the `%var%` has successfully stored the value of `"lemon"`.  

However, the following command **`echo %var%`** output is **`ECHO is off.`**.

How does it happen?

The following is the batch script result capture from cmd. (`@echo off`)

```
var="apple"
ECHO is off.
"Text2"
var="orange"
ECHO is off.
"Text2"
var="pear"
ECHO is off.
"Text2"
var="lemon"
ECHO is off.
"Text2"
Press any key to continue . . .
```