|
Hidden test exist temporary in the source of this file
For %%imposible in (64 32 16 8 4 2) do SET N= N/2 (devide N with 2) My previous Batch program uses a third party utility "STRINGS.COM". If a variable N was 64, then I wanted to use 32. If N was set to 32 , then I wanted 16 and so on... but I will very soon substitute the "STRINGS.COM" file with the CHOICE command which performs; not only addition/subtraction but also multiplying/divide is possible! Examples: @------------------------------ rem (N/2) Devide N with two: ECHO %N%'|CHOICE /N/C24'8'''1'''''''3'''''''''''''''6 FOR %%N IN (1 2 4 8 16 32) DO IF ERRORLEVEL %%N SET N=%%N Note about errorlevel 3 (easy to see): if N contents no value, then the above syntax do returns N=2. @---------------- rem (X+8 -X/2) Add 8 to X and then perform a subtraction of X devided with 2: :: ECHO %X% | CHOICE /N/C:''EG24'8'''1'''''''3'''''''''''''''6 > NUL FOR %%G IN (09 10 12 16 24 40) DO IF ERRORLEVEL G%%G SET X=%%G Note: if X contents no value, then the above syntax returns X= "empty". @---------------- rem (X+9 -X/2) ECHO %X% | CHOICE /S/C'24'8''^1'''''''3''''''''''''e''6 FOR %%N IN (10 11 13 17 25 41) DO IF ERRORLEVEL ^%%N SET X=%%N Note: if X contents no value, then it returns X= "empty" but this example is country dependent of the OS. In Denmark where: (ECHO is "not" off), an exit code would be 30 (ECHO er slået fra), the variable X is set to 25. Ignore the ^ in my above CHOICE syntax. It's just to remember me about the value -8 in this subtraction. regards B, and you know where to find my Homepage. PS. HELP! I'll wait for your reply about my above English. : End Of Mission Impossible.