where the code is indented? Is this an issue with Windows 10 and/or microsoft edge browser?
I am using Firefox browser on a Windows 10 64bit PC for this thread and will check to see if my code copied
back to file has the same problem, characters that need to be edited out before the batch file will execute.
I would like your guidance on working with code blocks and variables not being recognized inside the block.
Thanks for setting me straight on this. Here is my puzzling code:
Code: Select all
@echo off & setlocal EnableDelayedExpansion
Set "array[0]=word3"
Set "array[1]=word2"
Set "array[2]=word1"
echo array before: & set array[
Set "idx1=0" & Set "idx2=2"
If 1 equ 1 (
Set "var=!array[%idx1%]!"
Set "array[%idx1%]=!array[%idx2%]!"
rem wrong syntax: Set "array(%idx2%]=!var!"
rem should be:
Set "array[%idx2%]=!var!"
)
echo( & echo var: %var% - array after: & set array[
endlocal & pause & exit /b
and the result:
array before:
array[0]=word3
array[1]=word2
array[2]=word1
var: word3 - array after:
array[0]=word1
array[1]=word2
array[2]=word1
I copied my batch code from this thread to a new file and it ran without the ascii char #160 issue.