0
@echo off
if not exist "c:\user_records" md c:\user_records
if [%1]==[] goto ask
set name=%~1
set username=%~2
if name==[] if username==[] (
@echo Error. I don't understand the perameters. Now switching to
@echo Interactive mode
goto int
)
goto save
:ask
@echo This program allows the user to create a username for them to use.
@echo When asked, please enter your name and chosen username. The
@echo program will create a .txt file with the chosen username as the title.
:int
set /p name="What is your name?"
set /p username="What is your username?"
:save
if exist c:\user_records\%username%.txt (
@echo This username already exists!
set /p username="Please enter another username:"
)
@echo %username%.txt was created
@echo %name% >>c:\user_records\%username%.txt
@echo %username% >>c:\user_records\%username%.txt
@echo %date% %time% >>c:\user_records\%username%.txt
如果用戶給出2個參數中的1個或多於2個,那麼它應該顯示一個錯誤消息,指出參數丟失並轉到int。但相反,它需要前兩個或只有一個。我該如何解決?錯誤如果超過2個輸入
我建議你不要用「讀操作」這句話,但「變量擴展」,而不是(這種改變也應該在的
username
的情況下進行)?恕我直言,一個_read operation_是什麼'設置/ P'命令不... – Aacini@Aacini,我明白你的意思,也許'retrieve'是一個更加明確的術語,'read',但對我來說'變量expansion'是這樣的解析器處理已編碼的值檢索請求。我選擇將它改爲*'calling' *,因爲它是Microsoft文檔中使用的術語。 –
@Aacini,並提及問題本身,是的,請提出你認爲可能有所幫助的一切。我只有一個頭,通常是不夠的。 –