POWERSHELL-BATCHFILE EXERCISE

Joined
Jan 28, 2023
Messages
5
Reaction score
0
@echo off
setlocal enabledelayedexpansion

rem create list
set a[0]=michael
set a[1]=pique
set a[2]=elias
set a[3]=george
set a[4]=tobias

rem based on the table above and using (for) command to create the following content display:
for /L %%i in (0,1,4) do (
set /a j=4-%i%
echo !a[%%i]! !a[%%j]!)
if %i% LSS 4 (
set /a i+=1
)
pause

Can someone help? I want make it work and show me that
michael tobias
pique george
elias elias
george pique
tobias michael
 
Joined
Jan 30, 2023
Messages
107
Reaction score
13
@echo off
setlocal enabledelayedexpansion

rem create list
set a[0]=michael
set a[1]=pique
set a[2]=elias
set a[3]=george
set a[4]=tobias

rem based on the table above and using (for) command to create the following content display:
for /L %%i in (0,1,2) do (
set /a j=4-%%i
echo !a[%%i]! !a[!j!]
)
pause

hummm ?
 
Joined
Jul 4, 2023
Messages
406
Reaction score
47
Second "for loop" used in that way inside first "for loop"

Bash:
@echo off
cls
setlocal enabledelayedexpansion

rem create list
set a[0]=michael
set a[1]=pique
set a[2]=elias
set a[3]=george
set a[4]=tobias

rem based on the table above and using (for) command to create the following content display:
for /l %%i in (0,1,4) do (
    set /a j=4-%%i
    for %%j in (!j!) do echo !a[%%i]! !a[%%j]!
)

echo.
echo.
echo Press ENTER
pause > Nul
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,818
Messages
2,569,727
Members
45,661
Latest member
NadineBour

Latest Threads

Top