Varmint Blink
Varmint Blink

Reputation: 23

CMD Compare two numbers from input

I need to compare 2 float numbers but always get stuck on the output... No matter what I input, the output is always the same. I was searching through the Web, found some articles, but none of them helped me. Here is the code

    @echo off
    SETLOCAL ENABLEDELAYEDEXPANSION

    set /p first = First: 
    set /p second = Second: 
    IF !first! GTR !second! (GOTO One) ELSE (GOTO Two)

    :One
    ECHO first
    GOTO Done

    :Two
    IF !first! LSS !second! (ECHO second) ELSE (ECHO Equal)
    GOTO Done

    :Done
    pause

Upvotes: 2

Views: 3541

Answers (1)

Magoo
Magoo

Reputation: 79983

set /p first = First:

should be

set /p first=First:

Spaces are significant on both sides of a set - the space would be included in the variable name.

Upvotes: 1

Related Questions