0

我做了这个代码

@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
)

现在您可能看到需要是 %variablename% 的 %!var!% yeh 知道吗?我需要解释更多,以便在修复此错误后完成其余批次的发货!在那之前,我仍然需要删除它在开始时回答自己的问题的那部分!

4

2 回答 2

1

您需要学习如何将代码提炼成提出问题所需的最少代码,然后提出特定问题。

话虽如此,我想我理解你的问题。

我相信您正在动态构建批处理脚本,并且您希望您的代码看起来像

echo If '%someVar%'=='someString' goto someLabel

要使输出中的百分比增加一倍,您需要做的就是将它们加倍

echo If '%%!var!%%'=='!string!' goto !poin! >> %dir101%
于 2012-04-16T01:55:12.023 回答
-1

只要 %%variable%% 真的很简单

于 2012-04-22T18:56:49.123 回答