Rob van der Woude's Scripting Pages
Powered by GeSHi

Source code for islarger_3rdparty.bat

(view source code of islarger_3rdparty.bat as plain text)

  1. @ECHO OFF
  2. SETLOCAL ENABLEEXTENSIONS
  3. SETLOCAL ENABLEDELAYEDEXPANSION
  4. SETLOCAL
  5. SET _FIRST=%1
  6. SET _SECOND=%2
  7. CALL :ISLARGER _FIRST _SECOND _ANSWER
  8. ECHO !_ANSWER!
  9. GOTO :END
  10.  
  11. :ISLARGER
  12.    ::DETERMINE IF FIRST VAR IS LARGER THAN SECOND
  13.    ::NUMBERS OF UP TO ~4000 DIGITS CAN BE COMPARED, NO MORE THAN ~8100 DIGITS COMBINED
  14.    ::SYNTAX: CALL ISLARGER _VAR1 _VAR2 _VAR3
  15.    ::hieyeque1@gmail.com - drop me a note telling me
  16.    ::if this has helped you.  Sometimes I don't know if anyone uses my stuff
  17.    ::Its free for the world to use.
  18.    ::I retain the rights to it though, you may not copyright this
  19.    ::to prevent others from using it, you may however copyright works
  20.    ::as a whole that use this code.
  21.    ::Just don't try to stop others from using this through some legal means.
  22.    ::CopyRight Brian Williams 5/18/2009
  23.    :: _VAR1 = VARIABLE AGAINST WHICH WE SHALL COMPARE
  24.    :: _VAR2 = VARIABLE TO BE COMPARED
  25.    :: _VAR3 = VARIABLE WITH TRUE/FALSE RETURNED
  26.    SET _NUM1=!%1!
  27.    SET _NUM2=!%2!
  28.    SET _RESULT=%3
  29.    FOR /L %%A IN (1,1,2) DO (
  30.       FOR /L %%B IN (0,1,9) DO (
  31.          SET _NUM%%A=!_NUM%%A:%%B=%%B !
  32.          )
  33.       )
  34.    FOR %%A IN (!_NUM1!) DO SET /A _NUM1CNT+=1 & SET _!_NUM1CNT!_NUM1=%%A
  35.    FOR %%A IN (!_NUM2!) DO SET /A _NUM2CNT+=1 & SET _!_NUM2CNT!_NUM2=%%A
  36.    IF !_NUM1CNT! NEQ !_NUM2CNT! (
  37.       IF !_NUM1CNT! GTR !_NUM2CNT! (
  38.          SET !_RESULT!=TRUE
  39.          GOTO :EOF
  40.          ) ELSE (
  41.          SET !_RESULT!=FALSE
  42.          GOTO :EOF
  43.          )
  44.       )
  45.    FOR /L %%A IN (1,1,!_NUM1CNT!) DO (
  46.       IF !_%%A_NUM1! NEQ !_%%A_NUM2! (
  47.          IF !_%%A_NUM1! GTR !_%%A_NUM2! (
  48.             SET !_RESULT!=TRUE
  49.             GOTO :EOF
  50.             ) ELSE (
  51.             SET !_RESULT!=FALSE
  52.             GOTO :EOF
  53.             )
  54.          )
  55.       )
  56.    SET !_RESULT!=EQUAL
  57.    GOTO :EOF
  58.  
  59. :END
  60.  
  61.  
  62.  

page last uploaded: 2017-08-21, 14:26