Special characters
Won't work (ASCII values of problem characters)
SET;==SET= (Perform a test on a special syntax)
Super-loop (not finished (and not for newbies))
Delimiters (nested variables)
"DJ.BATch" (Ctrl P G)
Characters (ASCII and cursors positions counts)
ASCII.bat, (ASCII value = %h% (hex), %d% (dec))
Characters that won't work with:
ERRORLEVEL: Numbers which are greater than 99999999
PS. Level 0 is equivalent to level 99999744
and 4400000257 is equivalent to level 1
BennyLevel, ASCII values 0 9 10 13 32 44 59 60 61 62 124
CHOICE, ASCII values 0 3 9 10 13 16 19 26 32 37 47 58 60 62 124
10 (0A hex) is okay but problems exist with most editors.
File Names, Win9x. ASCII values,
Long Names:
Range 0;31 and 34 42 47 58 60 62 63 92 124
Short:
Range 0;32 and 34 42 43 44 47 58 59 60 61 62 63 91 92 93 124
" * + , / : ; < = > ? [ \ ] |
Editors
MS-DOS Edit. This editor shows (not converts) a single TAB (ASCII 9) as
spaces. Looks as space: ASCII values: 0, 32 and 255.
Notepad shows the following characters as a single space: ASCII values:
0, 32 and 160.
Some values (ASCII 1 and other characters), can't be written [Alt+num]:
Use [Ctrl+P] [Alt+num].
ASCII 0: Can't be written with [Alt+0] or [Ctrl+P] [Alt+0]:
Use [Ctrl+@].
ASCII 9: Can't be written with [Ctrl+I] or [Alt+9]:
Use [Ctrl+P] [Ctrl+I] or [Ctrl+P] [Alt+9].
Hyper text markup language
Problems exist about ASCII value: 0.
Characters, which looks like
a space: 32 160 173.
a rectangle: 1;8 11;12 14;31 127 129 141 143;144 157.
An example of HTML <PRE> format, source code & Browser output:
[�]
[	]
[ ]
[ ]
|
[�]
[ ]
[ ] [ ]
|
About the SET command and how to perform a test on a special syntax
"SET;Variable=something" would be the same as
"SET Variable=something" (see the space between the SET and the Variable).
The first example above, would be something like this:
SET Chr=;
SET%Chr%Variable=something
Anyhow, just because a semicolon maybe between the SET and the Variable
doesn't mean that any character can be set to a variable named Chr.
The characters that can be used, range [001;255], [01;FF hex], are:
Dec: 09 10 32 44 58 59 61
Hex: 09 0A 20 2C 3A 3B 3D
Chr: TAB LF , : ; =
Notes: I tested this on Win98 and DOS 6.22 successful
except the colon (3A) which can't be used on old DOS.
How did I figured out of that?
The following batch file produces all the hex numbers
between and including 07 until 0C (see line 5 below:)
05 SET D=::|%COMSPEC%/E:2048/C%0 07 0C ## ::
: Number of "#" must match number of digits on both the 'items', 7 and C.
Between the below two lines is the program which used
the numbers to make a file named ~.tmp
22 IF ::==%D% GOTO EOF -----------------------------
34 IF %2==%6 EXIT. ---------------------------------
The ~.tmp file contents the hex number without CR-LF,
which goes to a file named ~.txt.
If the "SET t=!" is possible with a character such as
a semicolon between T and t, then !=%t% must be true.
@echo off %[Line number 15 maybe WRAPPED]%
if ::==%4 goto p
::set temp=d:
rem> %temp%.\~.txt
set d=::|%comspec%/e:2048/c%0 07 0C ## ::
set d=
find "~00"/v <%temp%.\~.txt |find ".."/n/v>%temp%.\~.tmp
echo A successful execution of successive ASCII values:> %temp%.\~.txt
copy /a %temp%.\~.txt +%temp%.\~.tmp %temp%.\~.txt > nul
copy /a %temp%.\~.txt con > nul
::Maybe "Notepad %temp%.\~.txt" or Edit /h %temp%.\~.txt
for %%v in (del pause cls GOTO:EOF) do %%v %temp%.\~.tmp
:p
if %3==%5 goto x [the below line were wrapped:]
for %%x in (0 1 2 3 4 5 6 7 8
9 A B C D E F ) do call %0 %1 %2 %3 %4 %5# %6%%x
goto eof
:x
if %1==%6 set d=
if '=='%d% echo. %6
if not %d%'==' echo. %6 Not used
if not %d%'==' echo.~%6~Not used..>>%temp%.\~.txt
if ::==%d% goto eof --------------------------------
set t=> %temp%.\~.tmp
for %%v in (~%6 rcx 3 w q) do echo %%v>>%temp%.\~.tmp
type %temp%.\~.tmp | debug.exe %temp%.\~.tmp >nul
type %temp%.\~.tmp>> %temp%.\~.txt
echo @prompt e0'set'%6't=!'d a$_rcx$_9$_w0$_q>%temp%.\~.bat
%comspec% /e:992/c%temp%.\~.bat | debug %temp%.\~.bat > nul
for %%v in ( call del ) do %%v %temp%.\~.bat
::if !==%t% copy /b %temp%.\~.txt+%temp%.\~.tmp %temp%.\~.txt>nul
if !==%t% echo. >>%temp%.\~.txt
if not !!==%t%! echo.~..>> %temp%.\~.txt
set t=
if %2==%6 exit. ------------------------------------
:EOF
If you remove the line:
if not %d%'==' echo.~%6~Not used..>>%temp%.\~.txt
along with all lines between ... eof ------------
and the line ... exit ---------------------------
then you'll get the first module, which I used to
make any number. Lines with a left margin are add
or modified. The program can easily be changed to
perform a test on another syntax, @prompt e0 etc.
Well, I never finished this one, hmmm.
@Super-loop:
The number of running through was 65025 so, I wanted to develop a loop,
which should be very much faster. The number of loops / running through
was for each number in the range of 7 through 22. I also calculated the
heighest frequency to 18 and an average of 17 (16.8). I executed my new
Super-loop and I used all the numbers in the range of 1 throughout 255.
PS. OOPS. February 2, 2001 6:52 am (Forgot to sleep so, see you later).
@ECHO OFF
@ %[ For Example: Set L=134918 ]% SET L= ø~~~~
FC NUL NUL >NUL %[Restores the ERRORLEVEL parameter. Exit code: zero.]%
IF NOT ERRORLEVEL 01 IF ERRORLEVEL %L% FOR %%D IN (SET GOTO) DO %%D B=0
SET B=
SET E=63
SET N=64
:SETERLEV.COM Requires DOS V2.0 or greater! ((c) 1990 by Jim Elliot)
SETERLEV.COM: %E%
IF ERRORLEVEL %L% SET B=%E%
IF '=='%B% FOR %%S IN (S GOTO:SETERLEV) DO %%STRINGS E= ADD %E%, %N%
STRINGS E= SUB %E%,%N% >NUL
STRINGS N= DIV %N%, 2
IF NOT %N%==0 FOR %%Y IN (SET GOTO:SETERLEV.) DO %%Y B=
:B
ECHO. You may use ERRORLEVEL: %L% (equivalent = %B%)
FOR %%L IN (SET:B SET:E SET:N SET:L SET:CMDLINE ECHO PAUSE CLS) DO %%L=
I will in the future, create more examples about how to
create batch, (instead of just creating programs). This
doesn't means that I will delete my Homepage, but since
programmers makes their own programs, then I think this
is more useful than uploading my own/new constructions.
@echo off
set %[Delimiter D=ASCII 032]% D= % %
echo Please input a number. Press [Esc] to continue:
:input
choice /c0123456789/n > nul
if not errorlevel 2 for %%v in (cls echo goto:end) do %%v.
for %%v in (0 1 2 3 4 5 6 7 8 9) do if errorlevel }%%v set i=%%v
for %%v in (cls echo) do %%v.%n%%i%
set N=%N%%I%
set M=%I%%M%
set W=%N%%D%%W%
set Q=%I%%D%%Q%
set B=%B%%I%%D%
set V0=%V0%%N%%D%
set V1=%V1%%D%%N%
set V2=%V2%%D%%N%%D%
set V3=%D%%V3%%N%%D%
set V4=%D%%V4%%D%%N%
set V5=%D%%V5%%D%%N%%D%
goto input
Let's say the input was: 123
(1 12 123 ) V0: Delimiter at END of each element.
( 1 12 123) V1: Delimiter in FRONT of each element.
( 1 12 123 ) V2: Delimitation BOTH, i.e.:
(delimiter; element; delimiter),...
( 1 12 123 ) V3: As V0 but included an OFFSET of delimiters,
which equals number of elements.
( 1 12 123) V4: As V1 but included an... (see above).
( 1 12 123 ) V5: As V2 but... (see V3).
:end
echo. Specified number in reverce order: (%M%)
echo. Digits: (%B%)
echo. Reverce (digits): (%Q%)
echo. Reverce(history): (%W%)
echo. History: (%V0%)
echo. (%V1%)
echo. (%V2%)
echo. (%V3%)
echo. (%V4%)
echo. (%V5%)
echo. Specified number: (%N%)
echo.
for %%v in (echo. pause cls) do %%v
for %%v in (B Q V0 V1 V2 V3 V4 V5 W N I D) do set %%v=
goto EOF
Notes about delimiters
Depending on the program and your solution, the variable V2: (see above)
would probably be used in a case as ECHO ( 210 121 212 ) | FIND " 21 "
An ASCII 255. It seems that the elements are NOT connected but they are.
An ASCII 7 as delimiter. If the data are present to the console, then it
seems that the elements are connected together as one data element. This
is true for DOS but an ASCII 7 chr would actually distinct each element.
An ASCII 32 [SPACE], simply distinct each element in the specified list.
choice /c:123 Now: Please choose a delimiter (D) % %
if errorlevel 1 set %[Delimiter D=ASCII 032]% D= % %
if errorlevel 2 set %[Delimiter D=ASCII 255]% D=ÿ% %
if errorlevel 3 set %[Delimiter D=ASCII 007]% D=% %
:: The following (DJ.BAT) uses an ASCII 59 character
:EOF
Goto DJ.BATch
Outsider, (MSDOS.BATCH) wrote: Do you have a list of the keys
(including [Alt] + [NbrPad] that won't work with CHOICE? Have
you, or anyone, found a way for [Enter] to work (not Alt+11)?
I don't have such a list but if I create a list, then I would
upload it to this page; Done. The ASCII values that I sent in
my previours e-mail was used about the command COPY CON file.
Therefore, the ASCII value 27 were included in the following:
Except ASCII value 9 (TAB), the following characters was also
a problem, i.e.: when I created the stuff, shown on the page:
http://users.cybercity.dk/~bse26236/batutil/help/CHOICE_E.HTM
0 3 6 8 10 13 16 19 26 27 and 32 but also ASCII values of 60,
62 and 124, and perhaps ASCII value 160 and other characters?
BTW. Your, [Alt + 13] on the num keyboard: It's the same as Ctrl +
hmmm? I simply forgot this second character but the following
batch program can very faaast, tell about which key to press:
:: Example. The character of ASCII value seven makes a sound:
ECHO Hello "Now: Hold [Ctrl], press [P], press [G]" World!
:: And you can now exit your MS-DOS Editor and see the World!
:: with sound included. --b.pedersen, http://2dos.homepage.dk
:DJ BAT from Benny to Outsider. January 12, 2001. DOS6.22 + Win98:
@Find "__WRAP__" %0 >Nul
@If not errorlevel 1 For %%v in (Edit rem:or:Notepad Cls Goto:EOF) do %%v %0
@echo off
if not %1'==' goto: Local^Call
echo Input an ASCII Code, two digits (dec). Range(00;31):
choice /n /c'''0123 >nul
for %%d in (0 1 2 3) do if errorlevel J%%d %[+4. 74 = ASCII(J)]% set j=%%d
:: J. Read +4, thereby: range FOR in (4;7).
if errorlevel 000J3 choice /n /c'''''''01 %j%
if not errorlevel 7 choice /n /c'''''''0123456789 %j%
for %%J in (0 1 2 3 4 5 6 7 8 9) do if errorlevel d%%J %[+8]% set j=%j%%%J
:: Status: we got a number j, range(00;31).
call %0 00;@ 01;A 02;B 03;C 04;D 05;E 06;F 07;G 08;H 09;I 10;J 11;K 12;L 1
__WRAP__3;M 14;N 15;O 16;P 17;Q 18;R 19;S 20;T *
if not %j%'==' %0 21;U 22;V 23;W 24;X 25;Y 26;Z 27;[ 28;\ 29;] 30;^ 31;_ *
goto EOF
:Local^Call.
if not %j%==%1 if not %1==* for %%v in (shift shift goto:Local^Ca.) do %%v
if %1==%j% echo. ^%2 Alt + Num Keys(%1) = Hold Ctrl, press P and press %2
if %1==%j% set j=
:: Note: If you are not using an OS as DOS 6.22, (or below DOS 6.22), then
:: you should substitute the last line/following syntax: if %1==%j% set j=
:: with the commands: if %1==%j% for %%v in (set:j echo pause cls) do %%v=
:: OOPS: 76 characters is a limit for each line on my Homepage! Therefore,
:: the previous "calling line" got a WRAP (it's broken) so, you have
:: to unwrap this into 116 characters (instead of 76+40 characters).
:EOF
The following batch program wrote a text file with ALL
characters, (ASCII values 0 and 255 are included!). To
see an ASCII value: see the cursors positions counter.
@ECHO OFF
@SET F=%0
@ECHO %0? | FIND /I ".BAT?" > NUL
@IF ERRORLEVEL 1 SET F=%0.BAT
@FIND "E 0280 20 42 65 6E 6E 79 20 50 65 64 65 72 73 65 6E 2C" < %F% > NUL
IF ERRORLEVEL 1 FOR %%@ IN (ECHO.Fileÿnotÿfound:[%F%] GOTO:Written) DO %%@
@REM>ALL_CHAR.TXT
FIND /V "@" < %F% | DEBUG ALL_CHAR.TXT > NUL
@DIR ALL_CHAR.TXT
GOTO Written @
E 0100 20 20 20 20 20 20 20 20 7C 7C 20 20 7C 0D 0A 31
E 0110 32 33 34 35 36 37 38 39 30 31 32 33 34 35 20 20
E 0120 54 6F 20 73 65 65 20 61 6E 20 41 53 43 49 49 20
E 0130 76 61 6C 75 65 2C 20 75 73 65 20 74 68 65 20 63
E 0140 75 72 73 6F 72 20 70 6F 73 69 74 69 6F 6E 3A 0D
E 0150 0A 20 20 20 20 20 20 20 20 7C 7C 20 20 7C 0D 0A
E 0160 01 02 03 04 05 06 07 08 7C 7C 0B 0C 7C 0E 0F 10
E 0170 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F 20
E 0180 21 22 23 24 25 26 27 28 29 2A 2B 2C 2D 2E 2F 30
E 0190 31 32 33 34 35 36 37 38 39 3A 3B 3C 3D 3E 3F 40
E 01A0 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50
E 01B0 51 52 53 54 55 56 57 58 59 5A 5B 5C 5D 5E 5F 60
E 01C0 61 62 63 64 65 66 67 68 69 6A 6B 6C 6D 6E 6F 70
E 01D0 71 72 73 74 75 76 77 78 79 7A 7B 7C 7D 7E 7F 80
E 01E0 81 82 83 84 85 86 87 88 89 8A 8B 8C 8D 8E 8F 90
E 01F0 91 92 93 94 95 96 97 98 99 9A 9B 9C 9D 9E 9F A0
E 0200 A1 A2 A3 A4 A5 A6 A7 A8 A9 AA AB AC AD AE AF B0
E 0210 B1 B2 B3 B4 B5 B6 B7 B8 B9 BA BB BC BD BE BF C0
E 0220 C1 C2 C3 C4 C5 C6 C7 C8 C9 CA CB CC CD CE CF D0
E 0230 D1 D2 D3 D4 D5 D6 D7 D8 D9 DA DB DC DD DE DF E0
E 0240 E1 E2 E3 E4 E5 E6 E7 E8 E9 EA EB EC ED EE EF F0
E 0250 F1 F2 F3 F4 F5 F6 F7 F8 F9 FA FB FC FD FE FF 0D
E 0260 0A 20 20 20 20 20 20 20 20 7C 7C 20 20 7C 0D 0A
E 0270 20 20 30 3A 2D 28 00 29 7C 7C 20 20 7C 20 20 20
E 0280 20 42 65 6E 6E 79 20 50 65 64 65 72 73 65 6E 2C
E 0290 20 68 74 74 70 3A 2F 2F 32 64 6F 73 2E 68 6F 6D
E 02A0 65 70 61 67 65 2E 64 6B 2F 20 7E 7E 7E 7E 7E 40
E 02B0 0D 0A 20 20 39 3A 2D 2D 2D 28 09 29 20 20 0D 0A
E 02C0 20 31 30 3A 2D 2D 2D 2D 28 0A 29 20 0D 0A 20 31
E 02D0 33 3A 2D 2D 2D 2D 2D 2D 2D 28 0D 29 0D 0A 0D 0A
RCX
1E0
W
Q
:Written are all characters (ASCII 64 (@) is included)
@SET F=
Here's another version:
I found some of the code in an old book :-)
@echo off
if exist %0.bat %0.bat @
find /v "@" < %0 | debug > nul
goto eof @
N C:~SHOWCHR.COM
A
MOV AH,8
INT 10
MOV BH,AH
MOV AX,0600
XOR CX,CX
MOV DX,1849
INT 10
XOR DX,DX
XOR BH,BH
MOV CX,1
PUSH AX
MOV AH,02
INT 10
POP AX
MOV AH,0A
INT 10
INC AL
ADD DL,2
CMP DL,40
JNZ 12F
INC DH
XOR DL,DL
CMP AL,FF
JNZ 0117
RET
@ Next line is blank:
RCX
34
W
Q
:eof @
@c:~showChr
ASCII.bat
: Returns the ASCII value of a character in both hex and decimal values.
: Construction by Benny Pedersen, May 9, 2001.
@set char=A
@echo off > %temp%.\~.bat
rem > %temp%.\~.dat
for %%v in (e0'%char%' d0L1 q) do echo %%v>>%temp%.\~.bat
type %temp%.\~.bat | debug>%temp%.\~.bat
for %%v in (rcx 9 e115'set'9'%%1'3D w115 q) do echo %%v>>%temp%.\~.dat
debug %temp%.\~.bat < %temp%.\~.dat > nul
call %temp%.\~.bat h
rem > %temp%.\~.bat
rem > %temp%.\~.dat
for %%v in (rcx 7 f100'set'9'%%1'3D w q) do echo %%v>>%temp%.\~.bat
type %temp%.\~.bat | debug %temp%.\~.bat > nul
for %%v in (rcx %h% f0L%h%''A w0 q) do echo %%v>>%temp%.\~.dat
type %temp%.\~.dat | debug %temp%.\~.dat > nul
find ""/v/c<%temp%.\~.dat>> %temp%.\~.bat
call %temp%.\~.bat d
echo. The ASCII value of character %char% is %h% (hex), %d% (dec).
for %%v in (char h d) do set %%v=
erase %temp%.\~.?at
|