-3

I have solved my previous question but after editing, I started adding some lines. This is supposed to ask for the age and all that works for me is EQU and not LESS or GREA; So only "No" works. Everything else= "The syntax of the code is wrong." Thanks for helping previously, though! Possibly even this one. I can not be bothered to add 4 lines to the beginning of all my code BTW so is there any tips to help me do it quicker:

:Next1
echo You know, %name%, I just really cannot differ how old  you are. I would       love to know. Do not hesitate to say "No" if  you would not really like to  tell me, but I would like to know.
set /p age
if /i  "%age%" EQU "No" goto :NoAge
if /i "%age%" LESS 12 goto :Young
if /i "%age%" GREA 12 goto :Older
:Older
if /i "%age%" LESS 18 goto :Teen
goto :Adult
:Young
echo Oh, so you are quite young, are you! Well, that is ok, we can still have a little chat!
set "%age%" Young
:Teen
Oh, a teenager... I AIN'T MESSIN' WIT' YOU!
pause
end
:Adult
echo Ah, a good old adult. Lovely!
set "%age%" Older
goto :Next2
:NoAge
echo Well, that is ok (as I did say!) So, do not worry!
goto :Next2
:Next2
pause
sirfused
  • 21
  • 1
  • 1
  • 7
  • 2
    considered to read `if /?`? It's `lss` and `gtr` (or `leq` and `geq`) – Stephan Oct 28 '16 at 18:15
  • 1
    you should also check the syntax for `set` – Stephan Oct 28 '16 at 18:18
  • Oh, ok. I will check – sirfused Oct 28 '16 at 18:20
  • 1
    Please learn to read documentation. For batch commands, type the name of the command followed by `/?` at the command prompt. In this case, `if /?` would very easily have helped you figure this out in far less time than it took you to post here. A very good reference for most command-line functionality can be found at this [Command Line Reference](http://technet.microsoft.com/en-us/library/cc754340.aspx) page. – Ken White Oct 28 '16 at 18:21
  • The thing is, I (and you can call me an idiot...) do not know what a syntax is, so I would appreciate help still for the set commands if there is a problem with them (-: – sirfused Oct 28 '16 at 18:22
  • 1
    For Pete's sake. Type `set /?` at a command prompt. Are you even reading the words we're writing? – Ken White Oct 28 '16 at 18:23
  • Yes, I understand now: I did know you could do that but I was not thinking, @Ken White – sirfused Oct 28 '16 at 18:23
  • I just recieved your message. I am sorry, but also, that actually does not explain my problem. At least @Stephan is being polite. – sirfused Oct 28 '16 at 18:25
  • @Stephen You there? Not to be rude, though, it just seems as you have dissapeared! – sirfused Oct 28 '16 at 18:27
  • well, I *did* dissapear. It was time to call it a day in my part of the world `;)` – Stephan Oct 29 '16 at 08:35
  • But I have solved this question, so do not worry – sirfused Oct 29 '16 at 10:30

1 Answers1

0

here are a few changes, before carrying on with your project you really do need to do some reading.

:Next1
echo You know, %name%, I just really cannot tell how old you are.
echo Do not hesitate to say "No" if you would not really like to tell me,
set /p "age=but I would like to know. "
if /i "%age%" EQU "No" goto :NoAge
if "%age%" LSS "12" goto :Young
if "%age%" GTR "12" goto :Older
goto :Next1
:Older
if "%age%" LSS "18" goto :Teen
goto :Adult
:Young
echo Oh, so you are quite young, are you!
echo Well, that is ok, we can still have a little chat!
set "age=Young"

:Teen
Oh, a teenager... I AIN'T MESSIN' WIT' YOU!
pause
exit
:Adult
echo Ah, a good old adult. Lovely!
set "age=Older"
goto :Next2
:NoAge
echo Well, that is ok (as I did say!) So, do not worry!
goto :Next2
:Next2
if /i "%age%" EQU "Young" goto :Young-next2
goto :Adult-next2
:Young-next2
echo Young %name%, would you like to play a game of rock, paper, scissors? (Y/N)
set /p "RPS=Y/N "
if /i "%RPS%" EQU "Y" goto :Yes
if /i "%RPS%" EQU "N" goto :No
goto :Young-next2

You need to fill in something at the blank line, probably a goto, depending upon how you are going to have a chat. If you don't do that the code will go straight into the :Teen label.

Compo
  • 36,585
  • 5
  • 27
  • 39
  • Could you please explain the changes you made? – sirfused Oct 28 '16 at 19:04
  • Oh, no, I didn't... Thanks – sirfused Oct 28 '16 at 19:07
  • At this time you would be better advised to compare the two side by side, read the material as mentioned in the other comments and try to work it out. Believe me doing it that way will be more fruitful than me telling you. – Compo Oct 28 '16 at 19:07
  • I have spotted the set changes: So that is what I had to do! – sirfused Oct 28 '16 at 19:08
  • But I am struggling to find more – sirfused Oct 28 '16 at 19:09
  • **LSS** not LESS **GTR** not GREA – Compo Oct 28 '16 at 19:10
  • I changed them before, just forgot to edit post as someone else pointed them out to me – sirfused Oct 28 '16 at 19:12
  • Is there any more? – sirfused Oct 28 '16 at 19:12
  • Spotted the 2 echo bit (not really bad code, but I guess it was a good idea so I have added it with a timeout of 1) – sirfused Oct 28 '16 at 19:17
  • I have made those edits but it says w is not recognised as an internal or external command. Where is this: I cannot find it. It is after selecting LSS 12 for age – sirfused Oct 28 '16 at 19:20
  • Oh, I did not even edit anything and it is not saying that anymore, great! – sirfused Oct 28 '16 at 19:24
  • I am just going to quickly check but is this right?: :Next2 if "%age%" EQU Young goto :Young-next2 goto :Adult-next2 :Young-next2 echo Young %name%, would you like to play a game of rock, paper, scissors? (Y/N) set /p Y/N-R.P.S if "%Y/N-R.P.S%" EQU Y goto :Yes if "%Y/N-R.P.S%" EQU N goto :No goto :Need-Answer;R.P.S :Yes :No :Need-Answer;R.P.S pause – sirfused Oct 28 '16 at 19:33
  • I would also suggest you mark correct answers as correct too. As you have seen some responders already find it difficult enough to find the motivation to help. Getting points for their answers helps them with that motivational block. – Compo Oct 28 '16 at 19:35
  • How do I do code thing in reply (tried 4 space before) – sirfused Oct 28 '16 at 19:35
  • you need to make sure that if your left side of EQU is enclosed in double quotes that your right side is too! – Compo Oct 28 '16 at 19:36
  • I have appended some text to the bottom of my answer to take account of the addition in your above comment, I hope it helps you out. – Compo Oct 28 '16 at 19:44