Hello, welcome batch programmer.
In this tutorial I will show you how to parse an output of command: Dir * \b and set an array element each to the each line output of the command.
In this tutorial we will
So, lets continue
PRE REQUISITE
1. You need to know about setlocal EnableDelayedExpansion
2. You need to know about how to use FOR /F and FOR /L basically. You can read it at my tutorial.
@echo off
REM This is a program for setting each array index value with for loop parameter value
setlocal EnableDelayedExpansion
REM Setting an array value with each for loop parameter value
FOR /L %%i IN (1,1,10) DO set a[%%i]=%%i
REM Outputting an array value with each for loop parameter value
FOR /L %%i IN (1,1,10) DO echo !a[%%i]!
You can also add the FOR /F loop parameter value to each array index:
In this tutorial I will show you how to parse an output of command: Dir * \b and set an array element each to the each line output of the command.
In this tutorial we will
So, lets continue
PRE REQUISITE
1. You need to know about setlocal EnableDelayedExpansion
2. You need to know about how to use FOR /F and FOR /L basically. You can read it at my tutorial.
@echo off
REM This is a program for setting each array index value with for loop parameter value
setlocal EnableDelayedExpansion
REM Setting an array value with each for loop parameter value
FOR /L %%i IN (1,1,10) DO set a[%%i]=%%i
REM Outputting an array value with each for loop parameter value
FOR /L %%i IN (1,1,10) DO echo !a[%%i]!
You can also add the FOR /F loop parameter value to each array index:
Tidak ada komentar:
Posting Komentar