开发者

problem with the set command in a batch file! please help

EDIT: Heres the link to the stringparsing.bat file incase the other one didnt work for you! http://www.drivehq.com/file/DF.aspx?sesID=yycd31uaiezsvh3qrcdzkk45&isGallery=&share=&shareID=0&forcedDownload=true&fileID=618297825

EDIT#2: The code snippet that i suspect to be the cause of the problem is:

set /p line1= :
echo %line1% >> %name%.txt 2> error_log.txt


echo %name% > Language_File.txt
attrib +h Language_File.txt
set /a foo+ =1
)
echo.
echo ==========================================================

goto LOAD



:LOAD
set /a foo+ =1
IF %foo%== 2 goto loadexternal开发者_C百科
goto LOAD23

:loadexternal
echo.
echo language file is loading now!
IF Exist Language_File.txt attrib -h Language_File.txt 
set /p name=<Language_File.txt

The program (for some reason) cannot find a text file based on the contents of another text file (language_file.txt) however ive tested it and it can be done, but just not in my program....


Ok so ive asked 3 different questions about the same batch file ive created (stringparsing.bat) the link to the other two questions can be found here:

"access denied" error message for a text file i just made?

So first there was a problem with setting multiple lines in a text file to one variable, which is now fixed. Then there were error messages coming up because i was trying to redirect to a hidden file which is fixed. Now the problem lies with the set /p command along with a variable (%name%). Here is the explantion of my problem (quoted from the bottom of the page in the link above)

"I got a problem.... i fixed the access denied error , however that "windows cannot find the file specified" error is really confusing, i tested it in a normal command line , "type frenchy.txt" displays the content of the text file that i created, "set /p var=%name%.txt" displays the error. however after that, i typed "echo %name%" and it displayed the content of the text file. so the problem lies with the use (or mis-use) of the set /p command with a variable."

If you need more information i highly suggest that you follow the link to my previous question(s). I started a new question because no one responded to it in the comment (probably because it was a totally different problem and therefore deserved a separate question.) Also, the suggested solution in which i marked as "the best answer" (with the green check mark) no longer works for me because of the error "windows cannot find the file specified" that keeps coming up... Ive narrowed it down to the set /p comand along with %name% variable being the cause of the error message but cant seem to understand what im doing wrong... at the end of this post ill add a link to my current version of the "stringparsing.bat" file ... Or if you would prefer to just see the script for it (note that this is not a recent copy of it) you can follow the link at the top to go to my earlier question (i have the script posted there) ive been working on this program for quite some time now but have only found more and more problems. Hopefully this will be the last one!

Heres the link to my current copy of the stringparsing.bat file: http://uploading.com/files/183m5b63/stringparsing.bat/

If you see any other problems then please let me know how i can fix them!

Thanks in advance!


set lang=french
echo rapidement > %lang%.txt
echo %lang%> language.txt

rem ....

set /p name=< language.txt
echo %name%
set /p vocable=< %name%.txt
echo %vocable%

This displays french and rapidement, as expected.

I suppose your problem is the space behind the language name in echo %name% > Language_File.txt So you will try to open a file named "french .txt" (in reality only for "french " is searched).

If you got problems, it is always a good idea to reduce the problem to the minimum of code. And then it is always a good idea to enable echo on

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜