![]() |
I have tried.. but I just can't get this
Hi. I have been trying to write this batch file (command prompt. bat file) for days now. It is due tomorrow. I am taking a degree in Computer Networking and We got asked to write a batch file. I cannot grasp computer syntax, I just find programming so difficult. I, have however, after so many hours, cans of red bull, stress, close to giving up, wrote a batch file that meets the criteria of whats been asked. All that is left now is for me to include FOR and IF into my program. Basically, my batch file Has 6 ERRORLEVELS, the 6th being quit, and 1 through 4 display a movie from a certain year simply using the findstr command. I have been trying for 8 hours to try and get my 5th errorlevel functioning. What I need it to do is Ask the User for Input. Basically saying "Please Enter A letter between A and Z to search through the list of movies". I have the list of movies sitting on my Floppy Disk, there is the title and then in brackets the year. So basically
Beautiful Boxer (2005) Moonshine (2006) ^^ that is a small part of my List.txt. The code I have right now is :
:BROWSEIn my findstr I have put /b so that is searches for the start of the text. Therefore I will get movies starting with that letter. So when My user enters the letter, it outputs the results to a file called moviesfound.txt, and then I am showing the contents of that file I have written to in my batch file. Please Guys, I know it says you should try yourself before asking homework questions, but I have tried so hard. I just don't know how to do this. Do I need the Set /p? I just need the user to enter some sort of temporary variable, then that variable to be searched for in findstr. Thanks:icon_neutral::confused: |
Re: I have tried.. but I just can't get this
Have you considered telling us how your attempts fail to meet your expectations, or shall we pull some stuff out of our butts and guess?
Remember, we're not going to benefit from your grade. Tell us something useful. |
Re: I have tried.. but I just can't get this
Quote:
Ok, well, :
:BROWSEWhat I am getting here When I run this Errorlevel is "Enter Letter to search movie starting with that letter: %1". Then nothing. I cant exit the program, I cant get back to the main menu. It just allows me to enter letters, and nothing happens. My expections is to have an Echo saying "Please Enter the letter" then somehow (and it is this part that confuses me most) I want to take that input, store it in a variable, and put that variable into findstr, where I can return the results of the movies based on the letter. So the user enters "C" they will get every result that starts with C. |
Re: I have tried.. but I just can't get this
:
:BROWSEAm I getting closer? Can you see What I am trying to achieve here? I want the users input to be stored in this variable and then have the variable searched for in the List.txt. When I ran the program I was able to enter a letter, but then my file closes it self. |
Re: I have tried.. but I just can't get this
ok I got it working using...
:BROWSE Echo %1 will be searched... echo. for %%i in (.\Movie_List\List.txt) do findstr /b /i /c:"%1" %%i >> moviesfound.txt if not errorlevel=1 (type moviesfound.txt) else echo There are no movies that start with letter '%1' del moviesfound.txt goto :begin I don't know how u guys do this programming/scripting. It's rocket science to me. I hope I never need to do another one of these. |
| All times are GMT -5. The time now is 2:22 PM. |
Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC