Kevin De Smet
Kevin De Smet

Reputation: 3

Cannot find bug in simple .CMD file

I cannot find my bug, after set /p sum=give nr %amount%: it closes. Does anybody have an Idea why ? thanks anyway;-)

    ::Made By QluPreX 29/01/2015
@echo off
cls
color a
:SET_NUM
    set /p tot=how many numbers:
    cls
    set amount=1    
    set sum_tot=0
    echo %tot%?
    set /p y_or_n=is that correct (y/n) ? :
    if  %y_or_n%==y (
        cls
        goto:GIVE_NUM
    ) ELSE (
        cls
        goto:SET_NUM
    )
:GIVE_NUM
    set /p sum=give nr %amount%:
    set /a sum_tot=%sum_tot%+%sum%
    set /a amount=%amount%+1
    if /I %amount%==%tot%(
        goto:DISPLAY
    )ELSE(
        goto:GIVE_NUM
    )
:DISPLAY
    echo total is %sum_tot%
    pause 

Upvotes: 0

Views: 69

Answers (1)

Magoo
Magoo

Reputation: 79983

No idea what you mean by set /p sum=give nr %amount%:

but

)ELSE(

Must be

) ELSE (

(spaces required)

equally,

if /I %amount%==%tot%(

must be

if /I %amount%==%tot% (

Upvotes: 1

Related Questions