Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Hi,
I'm looking for some code which can do the following:
starting with some parameter, which can be upper or lower case (or mixed), to be converted to upper case only.
ex.
@echo off
echo Param 1 : %1
(code to convert %1 to upper case)
echo This is your parameter, converted to upper case : %1

Hello, Miskva.
Do you really need the paremeter to be turned into uppercase, or you just want to make a case in-sensitive on a parameter? I mean, I'm imagining the possibility that your main goal is that, and so you've assumed turning the parameter to uppercase would be a good way.
Well, here follows a way to make a case insensitive comparison with a parameter on Win9x/DOS (on NT you can use IF /I). Let's suppose you wanna check if %1 is equal to "recurs", no matter the case:
set %1=---
if "%RECURS%"=="---" echo %1=RECURS (TRUE)
if not "%RECURS%"=="---" echo %1=RECURS (FALSE)
set %1=And here follows a way to turn a parameter (%1, in this sample) to uppercase:
@echo off
echo e00 BE 00 01 B4 61 80 FC 81 74 0B 38 24 74 04 FE> %temp%.\T1.DAT
echo e0F C4 EB F3 80 2C 20 46 E2 EB 89 F1 81 E9 00 01>> %temp%.\T1.DAT
echo g=0 1e>> %temp%.\T1.DAT
echo w>> %temp%.\T1.DAT
echo q>> %temp%.\T1.DAT
echo SET P1=%1> %temp%.\T2.BAT
DEBUG %temp%.\T2.BAT < %temp%.\T1.DAT > nul
call %temp%.\T2.BAT
for %%? in (T1.DAT T2.BAT) do del %temp%.\%%?
echo "%1" in uppercase: "%P1%"Well, that's it. It's a little complex but it sure works.
-- Leonardo Pignataro - Secret_Doom --
secret_doom@hotmail.com
www.batch.hpg.com.br__________________________________________________________________________

Well, actually I need to compare a parameter with an IF statement, and therefor it needs to be the same case, ex.:
if "TEXT"=="text" ...
This would result in FALSE .. while it should be true. But, if you can use the IF command with the "I" param to have case-insensitive checks on NT (and also w2000 I suppose), then this is perfect .. !
Anyway, thanks for the code

I actually managed to make a stand alone assembler program that would convert the data from STDIN to uppercase, and print to STDOUT. That is nice because it can be used in various other situations, making the code more reusable.
But the source code is not so small. So, the source from the batch script to create such program with debug got big. However, if someone knows how to transform the binary code into ASCII (printable) code, it will be easier to create the program from the batch script. The source follows:
nnnn:0100 MOV DX,0131
nnnn:0103 MOV CX,0001
nnnn:0106 MOV BX,0000
nnnn:0109 MOV AH,3F
nnnn:010B INT 21
nnnn:010D OR AX,AX
nnnn:010F JZ 012F
nnnn:0111 MOV AH,61
nnnn:0113 CMP AH,81
nnnn:0116 JZ 0126
nnnn:0118 CMP [0131],AH
nnnn:011C JZ 0121
nnnn:011E INC AX
nnnn:011F JMP 0113
nnnn:0121 SUB BYTE PTR [0131],20
nnnn:0126 MOV BX,0001
nnnn:0129 MOV AH,40
nnnn:012B INT 21
nnnn:012D JMP 0106
nnnn:012F INT 20You see, to get that program created from a batch script, look at the source:
echo e100 BA 31 01 B9 01 00 BB 00 00 B4 3F CD 21 09 C0 74> %temp%.\T1.COM
echo e110 1E B4 61 80 FC 81 74 0E 38 26 31 01 74 03 40 EB>> %temp%.\T1.COM
echo e120 F2 80 2E 31 1 20 BB 1 0 B4 40 CD 21 EB D7 CD 20>> %temp%.\T1.COM
for %%? in (rcx 31 w q) do echo %%?>> %temp%.\T1.COM
type %temp%.\T1.COM |DEBUG %temp%.\T1.COM > nulThat's kinda big. However, if the code is converted to ASCII, the process to create the program is reduced, since instead of 3 characters on the batch script for each 1 character from the asm program, I would have 1 to 1. Besides, we skip the DEBUG part, using only ECHO.
If you don't know what I'm talking about, here's a batch script which will create an ASCII asm program:
echo XPYP[*'CC-\1P\QX,=P,APZ5O!PQ2O~5aaI~}Ksx> ASM.COM
See how its simpler (of course that asm source is smaller than the one I've created, but still the batch script source would be small).
Anyway, this was just an informative (and perhaps useless) post. =P
-- Leonardo Pignataro - Secret_Doom --
secret_doom@hotmail.com
www.batch.hpg.com.br_______________________________________________________________________________

Miskva wrote:
> But, if you can use the IF command with
> the "I" param to have case-insensitive
> checks on NT (and also w2000 I suppose),
> then this is perfect .. !Yeah, it's supported on Win NT 2K and XP. Actually, when I said "on NT you can use IF /I", I meant on NT systems (which refers NT 2K and XP), not Windows NT only.
Just keep in mind that will NOT work on DOS/Win9x.
-- Leonardo Pignataro - Secret_Doom --
secret_doom@hotmail.com
www.batch.hpg.com.br

I've just found out how to "ASCII-fy" the asm code. So, instead of this batch script:
@echo off
echo e100 BA 31 01 B9 01 00 BB 00 00 B4 3F CD 21 09 C0 74> %temp%.\T1.COM
echo e110 1E B4 61 80 FC 81 74 0E 38 26 31 01 74 03 40 EB>> %temp%.\T1.COM
echo e120 F2 80 2E 31 1 20 BB 1 0 B4 40 CD 21 EB D7 CD 20>> %temp%.\T1.COM
for %%? in (rcx 31 w q) do echo %%?>> %temp%.\T1.COM
type %temp%.\T1.COM |DEBUG %temp%.\T1.COM > nul
echo.SET P1=%1|%temp%.\T1.COM > %temp%.\T2.BAT
call %temp%.\T2.BAT
for %%? in (T1.COM T2.BAT) do del %temp%.\%%?
echo "%1" in uppercase: "%P1%"We can have this other, producing and using a different asm program, but which will do exately the same:
@echo off
echo `h}aXP5y`P]4nP_XW(F4(F6(F=(FF)FH(FL(Fe(FR0FTs*}`A?+,> %temp%.\T1.COM
echo fkOU):G*@Crv,*t$HU[rlf~#IubfRfXf(V#fj}fX4{PY$@fPfZsZ$:J=v$+>> %temp%.\T1.COM
echo CcCdO0Mz$9z98j{4X?MTQ70Q=:n0*_uA'$HWwdt[jWw5mZ'P$W@O[j{?_@k>> %temp%.\T1.COM
echo 3K?.]'=v?{+ZHu#>> %temp%.\T1.COM
echo SET P1=%1|%temp%.\T1.COM > %temp%.\T2.BAT
call %temp%.\T2.BAT
for %%? in (T1.COM T2.BAT) do del %temp%.\%%?
echo "%1" in uppercase: "%P1%"I just thought the size difference would be bigger, though. At least the second script doesn't require DEBUG.exe
-- Leonardo Pignataro - Secret_Doom --
secret_doom@hotmail.com
www.batch.hpg.com.br_______________________________________________________________________________________

![]() |
Screen shots in dos
|
Appending Text To Multipl...
|

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |