lundi 20 avril 2015

Trying to make a telef

I'm a beginner to batchscripting and I'm trying to make a telephoneregister that prints all, adds, deletes and searches for phonenumbers, but I can't get it to work correctly and I'm wondering where I did go wrong. The code is down below, thanks in advance.

echo Print out all content ^<1^> 
echo Add a new number ^<2^> 
echo Delete a number ^<3^> 
echo Search ^<4^> 
echo Exit ^<5^> 
set /p val="Choose between 1-5: " 

GOTO CASE_%val% 
:CASE_1 for /f "tokens=*" %%a in 
(telephoneregister.txt) do 
( echo %%a ) 
GOTO END_SWITCH 
:CASE_2 echo "Number: " set /p p1="Nr" 
echo %p1% >> %output%\telephoneregister.txt 
GOTO END_SWITCH 
:CASE_3 echo "Which number would you like to delete? " 
set /p num="Telephoneregister" 
type telephoneregister.txt | findstr /v %num% >telephoneregister.txt del /s telephoneregister.txt 
type telephoneregister.txt > tele.txt del /s tele1.txt 
GOTO END_SWITCH 
:CASE_4 set /p n1="Number: "
 findstr %n1% telephoneregister.txt 
GOTO END_SWITCH 
:CASE_5 exit 0
 GOTO END_SWITCH 
:END_SWITCH 
pause

Aucun commentaire:

Enregistrer un commentaire