Can't print (echo) a specific array element in a batchscript

can definition
can synonym
can verb
can y
can noun meaning
can band
cant
can't

I'm defining lists in a batch script and then like to print a specific element in each one of them, but getting an 'ECHO is off' output (is if it's empty).

I tried cycling trough the lists with a FOR loop and that worked fine.

This is the code for i'm trying to run

@echo off

rem --------start of Define list--------
set clist= A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
set ilist= X Y Z A B C D E F G H I J K L M N O P Q R S T U V W 
set testl= 1 2 3 4
rem --------end of Define list--------

echo %clist[1]%
echo %ilist[1]%
echo %testl[1]%

Expected output:

B
Y
2

Actual output:

ECHO is off
ECHO is off
ECHO is off

Here's an example using the method described here, for creating your array like variables:

@Echo Off & SetLocal EnableDelayedExpansion

Rem ------- Start of define list -------
Set "clist=A B C D E F G H I J K L M N O P Q R S T U V W X Y Z"
Set "ilist=X Y Z A B C D E F G H I J K L M N O P Q R S T U V W" 
Set "testl=1 2 3 4"
Rem -------- End of define list --------

Rem ------- Start of array lists -------
Set "i=0"
Set "clist[!i!]=%clist: =" & Set /A i+=1 & Set "clist[!i!]=%"
Set "i=0"
Set "ilist[!i!]=%ilist: =" & Set /A i+=1 & Set "ilist[!i!]=%"
Set "i=0"
Set "testl[!i!]=%testl: ="& Set /A i+=1 & Set "testl[!i!]=%"
Set "i="
Rem -------- End of array lists --------

Rem ----- Start your commands here -----
Echo %clist[1]%
Echo %ilist[1]%
Echo %testl[1]%
Pause
Rem ------ End your commands here ------

EndLocal & GoTo :EOF

Can, Can may refer to: Contents. 1 Containers; 2 Music; 3 Other; 4 See also. Containers[edit]. Aluminum can · Drink can · Oil can · Steel and tin cans · Trash can  Can definition, to be able to; have the ability, power, or skill to: She can solve the problem easily, I'm sure. See more.

If it was really your intention mimic an array, then it would be something similar to this.

@echo off
setlocal EnableDelayedExpansion

set "clist=A B C D E F G H I J K L M N O P Q R S T U V W X Y Z"
set /a cnt=0
for %%a in (%clist%) do (
   set "clist[!cnt!]=%%a"
   set /a cnt+=1
)
for /l %%i in (0,1,!cnt!) do echo( clist[%%i]=!clist[%%i]!

You can also separately echo the variables.

echo %clist[1]%`

The Official CAN / Spoon Records Website, VerbEdit. can (third-person singular simple present can, present participle -, simple past could, past participle (obsolete except in adjectival use) couth). Define can. can synonyms, can pronunciation, can translation, English dictionary definition of can. to be able to, have the power or skill to: I can take a bus to the

If your "array" member values are always 1 character long, then a single variable with substring operations is all that is needed.

@echo off

rem --------start of Define list--------
set "clist=ABCDEFGHIJKLMNOPQRSTUVWXYZ
set "ilist=XYZABCDEFGHIJKLMNOPQRSTUVW 
set "testl=1234
rem --------end of Define list--------

echo %clist:~1,1%
echo %ilist:~1,1%
echo %testl:~1,1%

rem Show all values in loop
setlocal enableDelayedExpansion
for /l %%N in (0 1 25) do (
  echo clist[%%N] = !clist:~%%N,1!
  echo ilist[%%N] = !ilist:~%%N,1!
  echo testl[%%N] = !testl:~%%N,1!
)

Can, can meaning: 1. to be able to: 2. used to say that you can and will do something: 3. to be allowed to: . Learn more. 110 synonyms of can from the Merriam-Webster Thesaurus, plus 97 related words, definitions, and antonyms. Find another word for can. Can: to bring (as an action or operation) to an immediate end.

can, 1.4Used to indicate that something is typically the case. 'antique clocks can seem out of place in modern homes'. More example sentences. A Controller Area Network (CAN bus) is a robust vehicle bus standard designed to allow microcontrollers and devices to communicate with each other's applications without a host computer. It is a message-based protocol , designed originally for multiplex electrical wiring within automobiles to save on copper, but can also be used in many other

CAN, Can-Am offers a complete lineup of Off-Road vehicles (ATV, Side-by-Side) and 3-​wheel motorcycles (Spyder or Ryker). Choose your playground now and enjoy  Looking for online definition of CAN or what CAN stands for? CAN is listed in the World's largest and most authoritative dictionary database of abbreviations and acronyms The Free Dictionary

Can, Can-Am Off-Road is an excellent place for those who dare to venture off-road. Discover our 2021 lineup: Side by Side and ATV for performance, adventure or  Can(stylised as CAN) was a German experimental rockband formed in Colognein 1968 by the core quartet of Holger Czukay(bass, tape editing), Irmin Schmidt(keyboards), Michael Karoli(guitar), and Jaki Liebezeit(drums).

Comments
  • A space separated list does not an array make. When cmd.exe people talk about an "array," they usually mean creating multiple variables. var[0], var[1], var[2], etc.
  • There is no any concept of lists or arrays in batch scripting, only normal environment variables (like VAR); but those are sometimes named like array-elements (like VAR[0], VAR[1], etc.), which I call usually pseudo-arrays. Take a loop at this post: Arrays, linked lists and other data structures in cmd.exe (batch) script