We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Demo source code:
array = [0, 1, 2, 3]; i = 2; // Wrong array[i] = 42; println("array[i] = " ++ array[i]); println("array = [" ++ array[0] ++ ", " ++ array[1] ++ ", " ++ array[2] ++ ", " ++ array[3] ++ "]"); println(); // Correct batch("set /a array_!i!=42"); batch("for %%i in (\"!i!\") do echo array[i] = !array_%%~i!"); println("array = [" ++ array[0] ++ ", " ++ array[1] ++ ", " ++ array[2] ++ ", " ++ array[3] ++ "]");
Compiled results:
@echo off setlocal EnableDelayedExpansion setlocal EnableExtensions set /a array_0=0 set /a array_1=1 set /a array_2=2 set /a array_3=3 set /a i=2 rem Wrong set /a array_i=42 echo array[i] ^= !array_i! echo array ^= [!array_0!^, !array_1!^, !array_2!^, !array_3!] echo: rem Correct set /a array_!i!=42 for %%i in ("!i!") do echo array[i] = !array_%%~i! echo array ^= [!array_0!^, !array_1!^, !array_2!^, !array_3!]
Execution output:
array[i] = 42 array = [0, 1, 2, 3] array[i] = 42 array = [0, 1, 42, 3]
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Demo source code:
Compiled results:
Execution output:
The text was updated successfully, but these errors were encountered: