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,并提及问题本身,是的,请提出你认为可能有所帮助的一切。我只有一个头,通常是不够的。 –