dcsimg
Results 1 to 2 of 2

Thread: [RESOLVED] Simple Batch file question

  1. #1

    Thread Starter
    Hyperactive Member Foxer's Avatar
    Join Date
    Oct 2001
    Location
    Australia
    Posts
    278

    Resolved [RESOLVED] Simple Batch file question

    I'm trying to do a number comparison in a ms-dos batch file. I have the following code

    set /a lastmonth_=%monthnr_%-1
    echo %lastmonth_%
    if %lastmonth_% < 10 set %lastmonth_% = 0%lastmonth_%
    echo %lastmonth_%

    the "< 10" isn't working - says something about < is unexpected.

    How do you do number comparisons in MS DOS batch files?

    Thanks.
    Rate my response if I helped

    Go Hard Or Go Home


  2. #2
    Fanatic Member Vectris's Avatar
    Join Date
    Dec 2008
    Location
    USA
    Posts
    941

    Re: Simple Batch file question

    You have to use abbreviations.

    LSS is less than
    LEQ is less than or equal to
    GTR is greater than
    GEQ is greater than or equal to

    Same for equals (EQU) and not equals (NEQ). If you just use a = then it automatically stores to the variable, even in an if statement.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width