skip to Main Content

Okay so I am currently creating a Artificial Intelligence program (VERY basic),
and I need to be able to log the name inputted by the user. I don’t understand from other articals posted.
Here’s the area of code:

set /p input= Before we talk, I'd like to ask your name so I can properly address you. Please print your name.
set /p Name= 

As you can see here, we have an input area and I need the file to save the inputted text, and re-open the file and use the name, every time you go onto this program.
Thanks in advance for any help!

2

Answers


  1. set /p Input=Enter name?
    echo set Input=%input% > "c:somefoldersomefile.bat"
    

    to use

    if not defined %input% call "c:somefoldersomefile.bat"
    

    See if /?, echo /?, and set /?.

    Login or Signup to reply.
  2. @echo off
    setlocal EnableDelayedExpansion
    
    call :GetName
    if not defined Name (
       echo Before we talk, I'd like to ask your name. Please print your name.
       set /p Name=
       echo set "Name=!Name!" >> "%~F0"
    ) else (
       echo Hello %Name%, I am glad to see you again.
    )
    
    rem The rest of the code goes here...
    
    
    goto :EOF
    
    rem Be sure that the next is the last line in this file:
    :GetName
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search