我制作了这段代码
@echo off & SETLOCAL EnableDelayedExpansion
title TXTanimation
set dir101=C:\USers\Jake\Desktop\file.bat
goto jakeinc
echo Lets make a text animation
pause
set /p dir101=where will the .bat be saved:
:jakeinc
echo @ECHO OFF > %dir101%
echo: >> %dir101%
:menu
echo 0=Edit important information
echo 1=Display .txt
echo 2=Play sound
echo 3=Close sound player
echo 4=Add nessicary wait between .txt
echo 5=Label point
echo 6=Edit variable
echo 7=Goto point
echo 8=Create IF sentence
echo 9=End it
echo Add - to the front to view it's guide!
Set /p choose=which one:
If '%choose%'=='0' (
SEt /p title=What is the title
:LOL101
set /p color=what color do you want type test to experiment with the colors
If '!color!'=='test' goto tester
goto model
:tester
SEt /p test=Please give hexadecimal number type exit to leave:
if '!test!'=='exit' goto LOL101
color !test!
goto tester
:model
echo title %title% >> %dir101%
echo color %color% >> %dir101%
goto menu
)
If '%choose%'=='-0' (
echo The title is on the top of the screen. The color of the text and backround is a hexadecimal number its
01,02,03,04,05,06,07,08,09,0A,0B,0C,0D,0E,0F,10,12,13,14,15,16,17,18,19,1A,1B,1C,1D,1E,1F,20,21,23,24,25...FB,FC,FD,FE. There really are
values with the same character but those are not valid colors in batch.
goto menu
)
If '%choose%'=='1' (
set /p dir=what is the dir of your .txt:
echo cls >> %dir101%
echo type %dir% >> %dir101%
goto menu
)
If '%choose%'=='-1' (
echo These pictures are what will be shown in the animation.
goto menu
)
If '%choose%'=='2' (
SEt /p dirx=What is the directory of the music file:
echo start !dirx! >> %dir101%
goto menu
)
If '%choose%'=='-2' (
echo Windows will open these sound files but may not automatically play them. If they are automatically played they should be opened one
nessicary wait before wanted time.
goto menu
)
If '%choose%'=='3' (
echo taskkill /PID wmplayer.exe >> %dir101%
goto menu
)
If '%choose%'=='-3' (
echo This closes the sound window when you play a sound. It should be played after a couple nessicary waits or when the sound is finished.
goto menu
)
If '%choose%'=='4' (
SEt /p thyme=How much milliseconds 250 is usual:
echo ping 192.168.1.1 -n 1 -w !thyme! ^>NUL >>%dir101%
goto menu
)
If '%choose%'=='-4' (
echo These waits are extremely important and should be used almost after every .txt.
goto menu
)
If '%choose%'=='5' (
SEt /p point=what do you want the point to be labeled as:
echo :!point! >> %dir101%
goto menu
)
If '%choose%'=='-5' (
echo You use this to label points where your animation can go back to.
goto menu
)
If '%choose%'=='6' (
:Y
SEt /p answ=Is this a math variable y/n
If !answ!==y goto yes
If !answ!==n goto no
goto Y
:yes
SEt /p name=variable name
set /p form=variable formula
echo Set /a !name!=!form! >> %dir101%
goto T
:no
SEt /p name=variable name
set /p form=variable value
echo Set !name!=!form! >> %dir101%
:T
goto menu
)
If '%choose%'=='-6' (
echo Variables can be used to count the number of times something has shown so you. If you put %variable name% it will use the value of that
variable.
goto menu
)
If '%choose%'=='7' (
SEt /p point=What point do you want to go to:
echo goto !point! >> %dir101%
goto menu
)
If '%choose%'=='-7' (
echo This is used to go back to points. THis is where you make infinite loops.
goto menu
)
If '%choose%'=='8' (
set /p var=which variable do you want to use
set /p string=What value should be questioned
SET /p poin=What is the name of the point
echo If '%!var!%'=='!string!' goto !poin! >> %dir101%
goto menu
)
If '%choose%'=='-8' (
echo IF sentences are usually used to do a command after a variable is a certain number.
goto menu
)
If '%choose%'=='-9' (
echo This is to close the batch.
goto menu
)
If '%choose%'=='9' (
echo Thanks for making
pause
exit /b
)
现在你可能会看到%!var!%yeh需要%variablename%吗?我需要解释更多,以便完成批处理的其余部分将在修复此错误后将其发送出去!在此之前,我仍然需要删除它在开始时回答自己的问题的部分!
答案 0 :(得分:1)
您需要了解如何将代码提炼为提出问题所需的最少代码,然后提出具体问题。
话虽如此,我想我理解你的问题。
我相信您正在动态构建批处理脚本,并且您希望代码看起来像
echo If '%someVar%'=='someString' goto someLabel
你需要做的就是让你的百分比在输出中加倍
echo If '%%!var!%%'=='!string!' goto !poin! >> %dir101%
答案 1 :(得分:-1)
只是%%变量%%它非常简单