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

出力でパーセントを取得するために必要なのは、それらを2倍にすることだけです。

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

ただ%%変数%%それは本当に簡単です

于 2012-04-22T18:56:49.123 に答える