Menu From the News
Page 3
Index
Index Page 2 | Page 4 | Nomenclature


     Convert to HEX, DEC, BIN or whatever.
     Rename myFile.tmp "Date Time"
     Hi, --Here's a little batch file to play with. --Loop
     Detecting the ram drive letter with use of only one line. (Win9x)
     A little study about the [Enter] key.
     Remember this question.
     Writing text on the DOS screen.
     Odd or even numbers.
     Get 8 (or less) characters into variable.
     Add Sub.






: CONVERT.BAT

  // Script by Lars Peter Thomsen. -- http://wsabstract.com/
  // Modified; Not case sensitive version by Benny Pedersen.

Tips: Jump with use of your Back Space key

Number to convert
Original scale, ex. 16 for hex, 10 for dec, 2 for bin, etc.
Destination scale

Result of Conversion.
@ ECHO OFF %-- Script language="Win9x/DOS BATch" --%
@ FIND "@"/v <%0> %temp%.\~Convert.htm
@ FOR %%@ IN (START rem:CLS DEL EXIT) DO %%@ %temp%.\~Convert.htm
  <html><head><title>Convert</title><style>body{background-color:
  #A9A9A9} A:visited,A:link {color:#00ff66; text-decoration:none}
  A:active,A:hover {background-color:#FFFAFA;color:#000066} TABLE
  {background-color:#000066;border:0px #000066 solid}</style></head>
  <body bgcolor="#000066" text="#FAEBD7" link=#00ff66 vlink=#00ff66>
  <script language="JavaScript">
  // Script by Lars Peter Thomsen. -- Modified; Not case sensitive
  // version by Benny Pedersen, http://users.cybercity.dk/~bse26236/
  function convert() {input=(document.formcon.Input.value);
  origin=(document.formcon.Origin.value);
  dest=(document.formcon.Destination.value);
  base="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"; c=0; Result="";
  for (t=1; t<=input.length; t++)
  {b=base.indexOf(input.substring(t-1,t).toUpperCase()); n=b*(Math.pow
  (origin, input.length-t)); c+=n} a=100; while (c< Math.pow (dest,a))
  { a--; } while (a>-1) {e=Math.pow (dest, a); a--; d=((c-(c%e))/e)+1;
  c=c%e; Ciffer=base.substring(d-1, d); Result = Result + Ciffer}
  document.formcon.output.value=Result}
  </script><br><table align="center" border="0"><tr><td>
  <font face="andale mono" size="2"><form name="formcon">
  <br><input type="text" name="Input" size="16"> Number to convert
  <br><input type="text" name="Origin" size="3"> Original scale, ex.
  16 for hex, 10 for dec, 2 for bin, etc.<br>
  <input type="text" name="Destination" size="3"> Destination scale
  <br><input type="button" onClick="convert(this.form.Input.value,
  this.form.Origin.value,this.form.Destination.value)"
  value="Calculate!"><br>
  <input type="text" name="output" size="16"> Result of Conversion<br>
  </form></font><a href="http://users.cybercity.dk/~bse26236/">:-)</a>
  </td></tr></table><br></body></html>
@ END//-- Use your mouse to click on this batch file; CONVERT.BAT --//


Rename myFile.tmp "Date Time"

According to DOS 6.22 is here a rewrite of my patchwork but of cause; you'll
only get the 8+3 file format in old DOS as usually.
Note: two lines got wrapped:

  @ECHO OFF
  REM> myFile.tmp
  ECHO::exit|%comspec% /k prompt ren:myFile.tmp;$d $t.*> %temp%.\~ren.bat
  ::============================================ MODULE FOR SUBSTITUTION:
  set object=%temp%.\~ren.bat
  set new=.
  set old=:

  set flag=> %temp%.\~.scr
  :Loop -----------------------
  find "%old%" < %object% > nul
  if errorlevel 1 goto End_Loop
:THE TWO WRAPPED LINES GOES HERE:
  echo exit|%comspec% /k prompt s100L64'%old%'$_q|debug %object%|find "-"/v>
%temp%.\~.scr
  echo exit|%comspec% /k prompt e104'e'$_e109'"%new%"'d a'w'd a'q'd a$_rcx$_
14$_w104$_q|debug %temp%.\~.scr>nul
  for %%v in (debug goto:Loop,) do %%v %object% < %temp%.\~.scr > nul
  :End_Loop -------------------
  set flag=%flag%#

  %[ Replace Comma (,) with Dot (.)           ]% set new=.
  if #==%flag%     for %%v in (set goto:loop) do %%v old=,
  %[ Replace Slash (/) with Minus (-)         ]% set new=-
  if ##==%flag%    for %%v in (set goto:loop) do %%v old=/
  %[ Replace Space ( ) with quote (')........ ]% set new=''
  if ###==%flag%   for %%v in (set goto:loop) do %%v old= % %
  %[ Fix an unwanted substitution............ ]% set new=ren:
  if ####==%flag%  for %%v in (set goto:loop) do %%v old=ren.
  %[ Fix an unwanted substitution............ ]% set new=:exit
  if #####==%flag% for %%v in (set goto:loop) do %%v old=.exit
  del %temp%.\~.scr
  for %%v in (object flag new old) do set %%v=
  ::============================================ END OF MODULE
  FOR %%' in (CAL DE) do %%'L %temp%.\~ren.bat


Hi,

Here's a little batch file to play with.
It can be used to whatever but as it is,
it returns the ASCII values as hex numb.

Benny Pedersen,

  PS. Labels and Goto's are placed in left margin. All other
      lines is prefixed with two spaces.

  Notes: Tested in Win 98.
         Three lines, (28, 31 and 42) got wrapped.
         If you are using PFE32 Editor, then you may press Ctrl-G and 42.

@GOTO %1#
:#####
  FOR %%e in (E HIF) do S%%eT L=%2
                    ECHO. e%L%0 %2
  if not (%3) == () ECHO. e%L%1 %3
  if not (%4) == () ECHO. e%L%2 %4
  if not (%5) == () ECHO. e%L%3 %5
  if not (%6) == () ECHO. e%L%4 %6
  if not (%7) == () ECHO. e%L%5 %7
  if not (%8) == () ECHO. e%L%6 %8
  if not (%9) == () ECHO. e%L%7 %9
  FOR %%e in (1 2 3 --------------4 5 6 7 8) do SHIFT
  if not (%2) == () ECHO. e%L%8 %2
  if not (%3) == () ECHO. e%L%9 %3
  if not (%4) == () ECHO. e%L%A %4
  if not (%5) == () ECHO. e%L%B %5
  if not (%6) == () ECHO. e%L%C %6
  if not (%7) == () ECHO. e%L%D %7
  if not (%8) == () ECHO. e%L%E %8
  if not (%9) == () ECHO. e%L%F %9
FOR %%v in (ECHO ECHO PAUSE CLS GOTO:EOF) do %%v.
:#
  @ECHO OFF
  echo Batch are reading each line... Step through...> %temp%.\~test.txt
  SET F=%temp%.\~test.txt
  echo exit|%comspec%/kprompt rcx$_$_q|debug %F%|find "CX">%temp%.\~
  echo exit|%comspec%/kprompt L2$_e0'd100L'$_eB'q'd$_rcx$_D$_w0$_q|debug %te
mp%.\~>nul
  debug %F%<%temp%.\~ |find ":">%temp%.\~
  echo exit|%comspec%/kprompt eFA'SET F='$_e104 d a$_rcx$_C$_n%temp%.\~.bat$
_wFA$_q|debug %temp%.\~>nul
  call %temp%.\~.bat
:##
:###
  FOR %%! IN (0 1 2 3 4 5 6 7 8 9 A B C D E F) DO CALL %0 #%1 %2%%! %2
GOTO EOF
:####
  IF 00==%3 GOTO EOF
  find "%F%:%20"<%temp%.\~>%temp%.\~.bat
  if errorlevel 1 for %%v in (del EXIT) do %%v %temp%.\~*
  echo exit|%comspec%/kprompt L5$_eA'SET L='$_e27 9$_rcx$_35$_wA$_q|debug %t
emp%.\~.bat>nul
  call %temp%.\~.bat
  call %0 #### %2 %L%
:EOF (wrap: 28 31 42)

:: Links: The nested zero tricks...
::        Outsider said: this is...

A brief description of some possibilities, (try it:)

@GOTO '%1
:'
  @ECHO OFF
:'#
:'##
  IF # ==%1 FOR %%v in (ECHO. PAUSE) do %%v -- Pause for each 100 --
  IF ##==%1 FOR %%v in (ECHO. PAUSE) do %%v -- Pause for each  10 --
  FOR %%! IN (0 1 2 3 4 5 6 7 8 9) DO CALL %0 #%1 %2%%! %3 %4 %%! %2
GOTO EOF
:'###
  ECHO.    %3''  '%4'  ''%5  %6'  %3'%5  '%4%5  %2
:EOF


Detecting the ram drive letter with use of only one line. (Win9x)

Frank-Peter Schultze wrote:

  BTW, determining the ramdrive letter using FINDRAMD.EXE and BennyLevel
  ERRORLEVEL Checking requires only two command lines:

    Findramd.exe
    For %%D In (C D E F G H I J K ...) Do If ErrorLevel H%%D Set RAMD=%%D

  Perhaps, Benny knows how to compress this into one line ;-)

Yes ---
    @echo off

  If two lines is to much, then use this one:

    Findramd.exe|FOR %%D in (C D E F G H I J K L M N O P Q R S T U V W X Y Z
) do if errorlevel H%%D set RAMD=%%D

  but the above variable %RAMD% maybe also is to much? ;-) so, use this one:

    Findramd.exe|FOR %%D in (Z Y X W V U T S R Q P O N M L K J I H G F E D C
) do if errorlevel H%%D %comspec%/cecho. (%%D)

  A good reson for not writing batch files in one line is that the temporary
  folder maybe filled up with files such as AABIGPIG so if you are using one
  of the above "one-lines", then I would suggest that you end the batch file
  as this: DEL %TEMP%.\*.

    FOR %%v in ("choice Erase" if:not" errorlevel 2 del/p" cls   ) do %%v %t
emp%.\*.
    :EOF

  Note: The "DEL %TEMP%.\*." won't include normal files or folders but files
        without an extension will be deleted (tested in DOS 6.22 and Win98).

  Link to all what is written about the BennyLevel: <Search all News Groups>


A little study about the [Enter] key
..
  @echo off
  echo.
  echo. Input your name:
  echo exit|%comspec%/kprompt e11E'set n'3D$_w$_q>%temp%.\~.bat
  fc /n nul /Lb1 con | find "1" >> %temp%.\~.bat
  type %temp%.\~.bat | debug       %temp%.\~.bat >nul
  type %temp%.\~.bat | find "=" >  %temp%.\~.bat
  for %%v in (call del cls) do %%v %temp%.\~.bat

  :----Loop
  echo.
  echo.%n%, input a number OR press Enter and Escape to quit:
  choice /n /c1234567890 /t,9 Input was: | find ""/v> con
  ::  27d 1Bh ----------^---^                07 ---^^-- 1Bh

  FOR %%v in %( Possible exit codes of FIND )% ( 0 1 2 ) do if errorlevel %%
v SET E=%%v
  FOR %%v in (ECHO.Errorlevel" %E%" "SET E=") do %%v

  FOR %%v in ("1 PAUSE" "0 CLS" "1 GOTO ----Loop") do if errorlevel %%v
  SET N=
  GOTO EOF

  Notes:
     An input, which is not specified as an option in the CHOICE command, do
     return the character of ASCII value 7. So, also other keys than [Enter]
     which are followed by an [Esc] key press, do causes this batch to exit.

  The below line, (discovered hmmm, constructed: August 26 2001),
     FOR %%v in ("1 PAUSE" "0 CLS" "1 GOTO ----Loop") do if errorlevel %%v
  can be substituted with the following line:
     FOR %%v in (pause:00000001 cls:00000000 goto:----Loop00000001) do if er
rorlevel %%v %%v

  :EOF -- The below batch file will also allow you to press the [Enter] key:


Remember this question

     @echo off
     echo.
     %COMSPEC%/Y/CRemember this question: Is CHOICE.COM in drive A:|FIND "N
">NUL
     FOR %%! IN (0 1 2) DO IF ERRORLEVEL %%! SET E=%%!
     FOR %%v in ("0 ECHO. Errorlevel %E%" "0 ECHO." "0 ECHO. No" "1 ECHO. Hm
mm, on second thought, I think your answer was Yes") do if errorlevel %%v
     echo.
     %COMSPEC%/Y/C :: (two colons) instead of the above Rem[ASCII 7]ember:|F
IND "Y">NUL
     echo. Okay.

     REM ----    Try: Substitute the NUL with CON

  Note:  Use a "N" instead of "Y". Since the Y in YES is language sensitive,
         then it's better to use FIND "N" for N in NO than using a letter Y.


Writing text on the DOS screen

  FIND and four quotes. Discovered: August 27, 2001.
  Benny, PS: Use the [Alt+Left Enter] key to toggle.

  @echo off
  echo.
  echo. Write your text on the DOS screen. When done, press [Ctrl+Break] or
[Ctrl+C]...
  echo. If you want to keep your text, then remember to copy and paste befor
e you exit.
  echo.---------------------------------------------------------------------
-----------
  %comspec%/cfind """"
  :: OR: %comspec%/cfind ""<con
  Notepad %0


Odd or even numbers

@echo off
set n=146255181346321643201345152164058316785437616494128
set n=:ÿ%n%
::     ^---- FF (255d)
FOR %%! IN (Even%n% Odd%n%.) DO %COMSPEC%/cIF ERRORLEVEL %%!000000 ECHO.%%!
::                 ^---- 08.
::       The extra line: "set n=:ÿ%n%" was add to avoid line wrapping.

::          [ NOT NOT ]
%COMSPEC%/cIF         errorlevel %n%0000000 ECHO Last digit of %n% is even

::            NOT
%COMSPEC%/cIF NOT errorlevel %n%0000000 ECHO Last digit of %n% is NOT even

::
%COMSPEC%/cIF NOT errorlevel %n%0000128 ECHO %n% is even, NOT odd.

:: Get rid of NOT. Just substitute the zero in the centre with a ` or an @
%COMSPEC%/cIF     errorlevel %n%000`000 ECHO Last digit of %n% is NOT even
%COMSPEC%/cIF     errorlevel %n%000@000 ECHO %n% is NOT even, %%n%% is odd
set n=

::  Test.bat
    @echo off
    choice/c12 Odd or Even --
    for %%v in (1 2) do if errorlevel %%v set n=%%v
    ::  Formula: (256n +128) where n is an integer.

    FOR %%! IN ("000 ECHO %n% is" "128 ECHO %n% is NOT") DO %COMSPEC%/cIF ER
RORLEVEL %n%0000%%! even

    REM or:
    FOR %%! IN ("0 ECHO %n% is even" "° ECHO %n% is odd") DO %COMSPEC%/cIF E
RRORLEVEL %n%000000%%!
    ::                   ASCII 176 ---^

    REM or:
    FOR %%! IN ("0 ECHO %n% is" "° ECHO %n% is NOT") DO %COMSPEC%/cIF ERRORL
EVEL %n%000000%%! even
    ::              ASCII 176 ---^

    REM -- I better like this one:

    FOR %%! IN (Even:ÿ%n% Odd:ÿ%n%.) DO %COMSPEC%/cIF ERRORLEVEL %%!000000
ECHO.%%!
    ::    ASCII FF---^   ^--08 ^-- FF (255d).

    set n=

::       google.com


Get 8 (or less) characters into variable
Tested in Win98.

  @echo off                   >%temp%.\~.bat
  :: Set a variable
       SET cmdline=1234testing

  :: Create a file, (unwrap all four lines to ONLY one line)
       ECHO exit|%comspec%/kprompt f1L8'%cmdline%'1A$_f100L50'set %%==='d a$
_e105'1'$_m1L1 107$_e10F'2'$_m2L1 111$_e119'3'$_m3L1 11B$_e123'4'$_m4L1 125$
_e12D'5'$_m5L1 12F$_e137'6'$_m6L1 139$_e141'7'$_m7L1 143$_e14B'8'$_m8L1 14D$
_rcx$_50$_w$_q|debug %temp%.\~.bat>nul

  :: Use the file
       CALL %temp%.\~.bat v1 v2 v3 v4 v5 v6 v7 v8

  :: Show contents of variable
       ECHO. %v1%%v2%%v3%%v4%%v5%%v6%%v7%%v8%
       ECHO. %v8%%v7%%v6%%v5%%v4%%v3%%v2%%v1%
       ECHO. %v1%%v5%%v2%%v6%%v3%%v7%%v4%%v8%
       FOR %%v in (%v1% %v2% %v3% %v4% %v5% %v6% %v7% %v8%) do echo. (%%v)
       ECHO. %v1% %v2% %v3% %v4% %v5% %v6% %v7% %v8%

  :: Clean up
       FOR %%v in (v1 v2 v3 v4 v5 v6 v7 v8) do set %%v=
       DEL %temp%.\~.bat

EXIT.  Notes:
     If length of string = c, then for c in [0;7], V(c+1) is set to blank:

       SET cmdline=12
       CALL %temp%.\~.bat V(1) V(2) V(3) V(4) V(5) V(6) V(7) V(8)

     would: set V(1)=1 and V(2)=2 and V(3) would be set to blank.

       FOR %%i in (0 1) do set V(%%i)=
       CALL %temp%.\~.bat V(0) V(1) V(1) V(1) V(1) V(1) V(1) V(1)
       IF not (%V(1)%) == () ECHO. Length is 8 or greater.
       SET

     Let the number of variable be one, (or greater) than needed:

       SET cmdline=12
       CALL %temp%.\~.bat V(1) V(2) cmdline

  Repeated with reversed parameters:

  End of the easy part. Now let us see if it can be used to solve a bit more
  difficult problem than just get numbers separated with space.

     Let us say that wee got a number and got 1, 2 or 3 digits.

       SET d=476

       ECHO exit | %comspec% /k prompt f1L8'%d%'  ...[snipped].
       CALL %temp%.\~.bat d100 d010 d001 cmdline

     No problems! but if our input was d=47, then wee got this:

       d100=4
       d010=7

     Solution:

       SET d=%d001%%d010%%d100%000
       ECHO exit | %comspec% /k prompt f1L8'%d%'  ...[snipped].
       CALL %temp%.\~.bat d001 d010 d100 d d d d

       d100=0
       d010=4
       d001=7

     Since 47 = 100(0) +10(4) +1(7), then it should be possible
     to take advange of this in next chapter which is about add
     numbers. Now u also know why I wrote the above batch file.

     Next chapter is written but it is also under construction.
<!-- -->
     @echo off

       SET d100=2
       SET  d10=7
       SET   d1=0

       SET n100=
       SET  n10=7
       SET   n1=0

       ECHO. (%d100%%d10%%d1% +- %n100%%n10%%n1%) =

     IF not (%d1%) == () GOTO got(d)
     ECHO. Input d, (max 3 digits):
     echo exit|%comspec%/kprompt e11f'SET d'3d$_w$_q>%temp%.\~.bat
     fc /n nul /Lb1 con |find "1">> %temp%.\~.bat
     type %temp%.\~.bat | debug.exe %temp%.\~.bat   >nul
     type %temp%.\~.bat |find "=" > %temp%.\~.bat
     call %temp%.\~.bat
     ECHO exit|%comspec%/kprompt f1L8'%d%'1A$_f100L50'set %%==='d a$_e105'1'
$_m1L1 107$_e10F'2'$_m2L1 111$_e119'3'$_m3L1 11B$_e123'4'$_m4L1 125$_e12D'5'
$_m5L1 12F$_e137'6'$_m6L1 139$_e141'7'$_m7L1 143$_e14B'8'$_m8L1 14D$_rcx$_50
$_w$_q|debug %temp%.\~.bat>nul
     CALL %temp%.\~.bat d100 d10 d1 d
     ECHO exit|%comspec%/kprompt f1L8'%d1%%d10%%d100%000'1A$_f100L50'set %%=
=='d a$_e105'1'$_m1L1 107$_e10F'2'$_m2L1 111$_e119'3'$_m3L1 11B$_e123'4'$_m4
L1 125$_e12D'5'$_m5L1 12F$_e137'6'$_m6L1 139$_e141'7'$_m7L1 143$_e14B'8'$_m8
L1 14D$_rcx$_50$_w$_q|debug %temp%.\~.bat>nul
     CALL %temp%.\~.bat d1 d10 d100 d1000 d d d
     :got(d)

     IF not (%n1%) == () GOTO got(n)
     ECHO. Input n, (max 3 digits):
     echo exit|%comspec%/kprompt e11f'SET n'3d$_w$_q>%temp%.\~.bat
     fc /n nul /Lb1 con |find "1">> %temp%.\~.bat
     type %temp%.\~.bat | debug.exe %temp%.\~.bat   >nul
     type %temp%.\~.bat |find "=" > %temp%.\~.bat
     call %temp%.\~.bat
     ECHO exit|%comspec%/kprompt f1L8'%n%'1A$_f100L50'set %%==='d a$_e105'1'
$_m1L1 107$_e10F'2'$_m2L1 111$_e119'3'$_m3L1 11B$_e123'4'$_m4L1 125$_e12D'5'
$_m5L1 12F$_e137'6'$_m6L1 139$_e141'7'$_m7L1 143$_e14B'8'$_m8L1 14D$_rcx$_50
$_w$_q|debug %temp%.\~.bat>nul
     CALL %temp%.\~.bat n100 n10 n1 n
     ECHO exit|%comspec%/kprompt f1L8'%n1%%n10%%n100%000'1A$_f100L50'set %%=
=='d a$_e105'1'$_m1L1 107$_e10F'2'$_m2L1 111$_e119'3'$_m3L1 11B$_e123'4'$_m4
L1 125$_e12D'5'$_m5L1 12F$_e137'6'$_m6L1 139$_e141'7'$_m7L1 143$_e14B'8'$_m8
L1 14D$_rcx$_50$_w$_q|debug %temp%.\~.bat>nul
     CALL %temp%.\~.bat n1 n10 n100 n n n n
     :got(n)

     SET d=+>%temp%.\~0.bat
     CHOICE /n/cp+m- Minus or Plus? % %
     IF errorlevel 3 SET d=-

     IF (+) == (%d%) ECHO FOR %%%%N IN (%%N%% 1 2 2 3 3 3 4 4 4 4 5 5 5 5 5
6 6 6 6 6 6 7 7 7 7 7 7 7 8 8 8 8 8 8 8 8 9 9 9 9 9 9 9 9 9) DO IF %%%%N==%%
N%% SHIFT>>%temp%.\~0.bat
     IF (-) == (%d%) ECHO FOR %%%%N IN (%%N%% 8 7 7 6 6 6 5 5 5 5 4 4 4 4 4
3 3 3 3 3 3 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0) DO IF %%%%N==%%
N%% SHIFT>>%temp%.\~0.bat

     SET j=1
     :R
       ECHO EXIT|%COMSPEC%/kPROMPT SET n=%%%%n%%j%%%%%%$_SET n%%j%%=$_:>%tem
p%.\~n.bat
       CALL %temp%.\~n.bat
     :R1
       ECHO EXIT|%COMSPEC%/kPROMPT SET X=%%%%%%d%j%%%$_:>> %temp%.\~0.bat
       IF (+) == (%d%) CALL %temp%.\~0.bat 0 1 2 3 4 5 6 7 8 9 10 11 12 13 1
4 15 16 17 18
       IF (-) == (%d%) CALL %temp%.\~0.bat 11 12 13 14 15 16 17 18 19 0 1 2
3 4 5 6 7 8 9
       FOR %%X in (0 1 2 3 4 5 6 7 8 9) do IF %%X==%X% GOTO next
       SET n=1
       FOR %%X in (0 1 2 3 4 5 6 7 8) do IF %n%%%X==%X% SET d%j%=%%X
     FOR %%v in (SET GOTO:R1) do %%v j=%j%0
     :next
       SET d%j%=%X%
       IF NOT (%n10%) ==() FOR %%v in (SET GOTO:R) do %%v j=10
       IF NOT (%n100%)==() FOR %%v in (SET GOTO:R) do %%v j=100
       ECHO. Result: %d1000%%d100%%d10%%d1%
       FOR %%v in (X j n d d1 d10 d100 d1000) do SET %%v=
       DEL %temp%.\~*.bat


-Top- Page 2 | Page 4 | Nomenclature