Filesize @echo off attrib %0 > %temp%.\~a.bat REM SET X = Size of file ~a.bat (hex) > %temp%.\~x.scr for %%v in (.rcx . .q) do echo%%v >> %temp%.\~x.scr debug %temp%.\~a.bat < %temp%.\~x.scr > %temp%.\~x.bat echo e106" SET X" 3D > %temp%.\~x.scr for %%v in (rCX E w106 q) do echo %%v>> %temp%.\~x.scr debug %temp%.\~x.bat < %temp%.\~x.scr > NUL call %temp%.\~x.bat echo. The size of "%temp%.\~a.bat" is %X% byte (hex), REM Remove the CRLF from the output to CON: "(dec):" > %temp%.\~x.scr for %%v in (L102 w F100LFF''1A L w102 q) do echo %%v>> %temp%.\~x.scr echo. (dec): > %temp%.\~x.bat debug %temp%.\~x.bat < %temp%.\~x.scr > NUL type %temp%.\~x.bat > CON REM And the file size is (dec): > %temp%.\~x.scr for %%v in (F0L%X%''A rCX %X% w0 q) do echo %%v>> %temp%.\~x.scr type %temp%.\~x.scr | debug %temp%.\~x.scr > NUL find /v /c "" < %temp%.\~x.scr del %temp%.\~*.* set X= Into environment variable : The following is based on a solution by William Allen so, it was NOT : a competition about, Who can write this more brief than another. The : @ECHO OFF was actually working. (Tested on Win98). : @echo off> %temp%.\~.bat for %%e in ( e5'SET'20'X'3D rcx 6 w5 q ) do echo %%e>> %temp%.\~.bat type %temp%.\~.bat |debug %temp%.\~.bat> nul echo Hello World>> %temp%.\~.bat : FIND "ot" < %0>> %temp%.\~.bat Into environment variables @echo off echo.. | choice /c'%1.> nul for %%v in (0 1 2 3 4 5 6 7 8) do if errorlevel 0}%%v set L=0%%v0 echo ~%1> %temp%.\~#.bat for %%v in (L0 f110L%L%''9''9''9''9''9''9'set'20'%%#'3D'#'D''A) do echo %% v>>%temp%.\~#.bat for %%v in (1 2 3 4 5 6 7 8) do echo e01%%vB'%%v'>>%temp%.\~#.bat for %%v in (1 2 3 4 5 6 7 8) do echo m%%vL1 1%%vD>>%temp%.\~#.bat for %%v in (rcx %L% w110 q ) do echo %%v>> %temp%.\~#.bat type %temp%.\~#.bat |debug %temp%.\~#.bat> nul call %temp%.\~#.bat n1 n2 n3 n4 n5 n6 n7 n8 for %%v in (%n1% %n2% %n3% %n4% %n5% %n6% %n7% %n8%) do echo. %%v for %%v in (L CMDLINE n1 n2 n3 n4 n5 n6 n7 n8) do set %%v= del %temp%.\~#.bat Put "quotes" around a text @echo off %{ QUOTES.BAT }% if not exist %1 call goto EOF rem: This batch code surrounds a text with quotes, i.e. "text" > %temp%.\~ for %%v in (L102 e101''22 w f100LFFF''22 L w101 q) do echo %%v >> %temp%.\~ debug %1 < %temp%.\~ > nul echo.>>%1 del %temp%.\~ :EOF %{ PS.: The ASCII value of a quote (") is 22 hex. }% Rik D'haveloose wrote: SNIP... Same tehnique could be used to get rid of the CR+LF charachters (hex 0D, 0A) from an echoed line of text (to append something later with echo.....), although i then would prefer to use hex20 (space) instead of the quote :-), and maybe some shorter version as: FOR %%v in (L102 e100''20''20 w q) do echo %%v>>%temp%.\temp.sfd ^^ ^^ Hi Rik, Yes hex 20 can be used but also hex A or hex 9 as: FOR %%v in (f0L2''A L2 w0 q) do echo %%v>>%temp%.\temp.sfd Benny. ^ Toolbox Updated April 2001, (click here to see the previous version). Maybe under construction in September 2001. (All previous got problems with COM files and I also got some new stuff 2 use). The following batch can be used to starting the DEBUG prompt. Some DEBUG commands i.e. suggestions are displayed before the DEBUG prompt. My suggestions which are available and ready to be copied and pasted can be used OR you can just ignore them. You can as usually type DEBUG or DEBUG FILE at the DOS prompt or you can use the below batch. Notis that 1 line is wrapped: @echo off if not exist %1 call goto: no_file. > %temp%.\~.bat echo e100''09''20''40'set'20'%%1'3D > %temp%.\~.scr for %%v in (rcx 10 w q) do echo.%%v>> %temp%.\~.scr for %%v in (.rcx . .q) do echo%%v>> %temp%.\~.bat type %temp%.\~.bat | debug %1 .... > %temp%.\~.bat debug %temp%.\~.bat < %temp%.\~.scr > nul call %temp%.\~.bat CX attrib %1 echo mB800:1A L126 B800:0 > %temp%.\~.scr echo fB800:A0 L084 '-' 32>> %temp%.\~.scr echo q >> %temp%.\~.scr debug < %temp%.\~.scr > nul for %%v in (. .f0LFFFF''20 .L .e0E0'0123456789ABCDEF') do echo%%v echo e0F0 0 1 2 3 4 5 6 7 8 9 A B C D E F for %%v in (dE0L20 d100L%CX%) do echo.%%v set CX= goto end :no_file for %%v in (. . .eF0''0''1''2''3''4''5''6''7''8''9''A''B''C''D''E''F .f10 0LFF00''20 .fE0L10'0123456789ABCDEF' .dE0LD0 .) do echo%%v :end echo m B800:A0L4E4 B800:BC> %temp%.\~.scr echo q >> %temp%.\~.scr debug < %temp%.\~.scr > nul debug %1 for %%v in (erase cls) do %%v %temp%.\~.* EXIT.--Maybe under construction in September 2001. @echo off if not exist %1 call goto:no_file. > %temp%.\~.bat echo exit|%comspec%/kprompt e100'set CX='$_rcx$_7$_w$_q|debug %temp%.\~.b at>nul echo exit|%comspec%/kprompt rcx$_$_ $Hfor %%%%%%%%v in (%%%%CX%%%%) do se t CX=L%%%%%%%%v$_q|debug %1|find "C">>%temp%.\~.bat for %%v in (cls call) do %%v %temp%.\~.bat [ CX ] attrib %1 echo %- COLORS -%exit|%comspec%/kprompt mB800:1AL126 B800:0$_fB800:A0L84' -'22$_q|debug>nul for %%v in (. .f0LFFFF''20 .L .eE0'0123456789ABCDEF') do echo%%v echo eF0 0 1 2 3 4 5 6 7 8 9 A B C D E F for %%v in (dE0L20 d100%CX%) do echo.%%v goto:end :no_file echo exit|%comspec%/kprompt $_eF0 0 1 2 3 4 5 6 7 8 9 A B C D E F$_f100LFF00 20$_eE0'0123456789ABCDEF'$_dE0LD0$_ :end echo %- OFFSET -%exit|%comspec%/kprompt mB800:A0L4E4 B800:BC$_q|debug>nul for %%v in ("set CX=" "debug %1" del:%temp%.\~.bat cls) do %%v ADD_hex.bat :Usage of ADD_hex.bat: call add_hex c [=] c + c :Example: c = 5 + FAC9 would return c = FACE (hex) = 05 + 64201 (dec). :Hint: x c + FFFE would return x = c - 2 (any value of c except c=1). echo h%2 %4> %temp%.\add_hex1.bat echo q>> %temp%.\add_hex1.bat debug<%temp%.\add_hex1.bat |find "-"/v> %temp%.\add_hex1.bat for %%v in (rcx B eF9'set'9'%%1'3D wF9 q) do echo %%v>> %temp%.\add_hex1.bat type %temp%.\add_hex1.bat|debug %temp%.\add_hex1.bat>nul call %temp%.\add_hex1 %1 del %temp%.\add_hex1.bat dec2hex.bat This file is based on an idea by Tom L. so, I tried several ideas and I also tested it for speed, etc... Example 1: (a file for testing the dec2hex.bat) @echo off call dec2hex 65535 echo %Hex% set Hex= Example 2: (a file for testing the dec2hex.bat) @echo off if not !!!!!'==%1' for %%! in (0 1 2 3 4 5 6 7 8 9) do call %0 %1! %2%%! if !!!!!==%1 call dec2hex %2 if !!!!!==%1 echo %Hex% if !!!!!==%1 echo %Hex%>> TESTING.TXT if %Hex%==0FA0 for %%v in (set exit) do %%v Hex= Several speed test have been performed. Thereby, the resulting file below has been changed very much. Note about line number 3: rem -------> -.tmp It seems that the syntax: ctty nul > -.tmp can't be used in any batch programs. They simply get unstable. This also includes the "CTTY CON > file.ext" So, never use it! @echo off > 0%1.# rem dec2hex> - rem -------> -.tmp ctty nul for %%v in (rcx 1 e100''A w q) do echo %%v>>- type - | debug - :opy for %%v in (0.# 0?.# 0??.# 0???.# 0????.#) do ren %%v 0%%v for %%v in (0 1 2 3 4 5 6 7 8 9) do if exist 0????%%v.# set Hex=%%v echo.%Hex% | choice /c0123456789 for %%v in (2 3 4 5 6 7 8 9 :) do if errorlevel %%v copy /b -.tmp+- if not exist 00000?.# copy /b -+-+-+-+- -A.tmp ren 0?????.# 0????.# >- if not exist 00000.# for %%c in (c c goto:) do %%copy /b -+-A.tmp for %%v in (r q) do echo %%v>>- debug -.tmp < - | find "AX=" >-.bat echo set Hex=%%5> AX.bat call -.bat ctty con for %%v in (-?.* 0*.# AX.bat) do del %%v
|