So I am experimenting with batch scripting and am trying to make something similar to snake. But I ran into a problem that I have no idea what causes it. Just when my first loop for start I get unexpected error about ")" after 3. I tried making another variable which has "1 2 3" and use that instead but still got almost same results. Just now it showed that do was unexpected.
Of course I can use if statements which obviously work as well but I was experimenting with goto to see if the speed of the script would increase. Because using if's it takes at least half or less second to output 3 lines.
@echo off
chcp 65001
mode con: cols=50 lines=25
setlocal EnableDelayedExpansion
echo. > test.txt
set array[1]=2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2
set array[2]=2 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 2
set array[3]=2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2
for %%b in (1, 2, 3) do (
for %%i in (!array[%%b]!) do (
echo Loop Begins
set LNr=%%i
echo Loop%LNr%
goto Loop%LNr%
:Loop0
echo 0
echo|set /p ="░" >> test.txt
goto LoopE
:Loop1
echo 1
echo|set /p ="█" >> test.txt
goto LoopE
:Loop2
echo 2
echo|set /p = "#" >> test.txt
goto LoopE
:LoopE
)
echo. >> test.txt
)
echo. >> test.txt
Also, any idea what characters I could use in ANSI encoding to avoid having to use UTF-8 and changing CMD font?
Aucun commentaire:
Enregistrer un commentaire