2012-04-16 69 views
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 
) 

現在你probaly看到,必須%VARIABLENAME%的任何想法%!VAR!%葉?我需要更多解釋,以便在修復此錯誤後,批處理的其餘部分完成發送。那麼在此之前,我仍然需要去清除它在開始時回答自己的問題的部分!

+3

這裏有問題嗎? – 2012-04-16 01:06:37

回答

-1

Just %% variable %%它真的很簡單

1

您需要學習如何將代碼提取到提出問題所需的最小代碼,然後提出具體問題。

這就是說,我想我明白你的問題。

我相信你是動態生成一個批處理腳本,你想你的代碼看起來像

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

所有你需要做的就是你的百分比在輸出翻倍起來

echo If '%%!var!%%'=='!string!' goto !poin! >> %dir101%