0

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
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!

Community
  • 1
  • 1
daniel11
  • 2,027
  • 10
  • 38
  • 46
  • can you create a small sample batchfile which shows the problem you have? I have a problem downloading the file, and I cant file the line "set /p var=%name%.txt" in the other question you link to. – wimh Dec 04 '10 at 22:01
  • i added a new link to the file at the top of this post, also , just go to my other question and you'll find the full code posted there, simply copy that script and try it out and you'll see the error (or you should). – daniel11 Dec 05 '10 at 01:29
  • It's simpler if you add the snippet and show the problematic lines – jeb Dec 05 '10 at 09:05
  • If you have problems formatting it, you can add it as an answer but mark it community wiki. That will allow others with a score of >100 to format it properly. – wimh Dec 05 '10 at 09:16
  • the problem occurs when the program creates the "language_file.txt" and then tries to set the contents of it as a variable (%name%) and then try to find the file with that variable as its name. for example: – daniel11 Dec 05 '10 at 22:11

1 Answers1

1
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

jeb
  • 78,592
  • 17
  • 171
  • 225
  • you are right, that is my current problem, (the space before the %name% variable in the file name) however i have tried everything and could not fix it, could you point ount in my script exactly where it is and how i could fix it? thanks! – daniel11 Dec 06 '10 at 20:33
  • k i figured it out your answer worked thanks! Its always the simplest mistakes that are the hardest to find ... – daniel11 Dec 06 '10 at 22:09