Weird arithmetic error in a simple script

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
Lamcourt
Posts: 2
Joined: 28 Oct 2015 14:16

Weird arithmetic error in a simple script

#1 Post by Lamcourt » 28 Oct 2015 14:26

Hello,
I have a very singular issue with this script :
@echo off
set /p L=L?
set /p l=l?
set /a s=%L%*%l%
echo s = %s%
pause
If L=5 and l=4, it gives me 16 as a result !!!! (L stands for Large and l stands for lentgh )

But if I replace L and l by a and b, it works perfectly

How comes ???

Thx a lot

Squashman
Expert
Posts: 4486
Joined: 23 Dec 2011 13:59

Re: Weird arithmetic error in a simple script

#2 Post by Squashman » 28 Oct 2015 14:48

Environmental variables are NOT CASE SENSITIVE!

Lamcourt
Posts: 2
Joined: 28 Oct 2015 14:16

Re: Weird arithmetic error in a simple script

#3 Post by Lamcourt » 28 Oct 2015 14:57

Waw ... so stupid of me... Thanks a lot :D

Squashman
Expert
Posts: 4486
Joined: 23 Dec 2011 13:59

Re: Weird arithmetic error in a simple script

#4 Post by Squashman » 28 Oct 2015 14:59

Lamcourt wrote:Waw ... so stupid of me... Thanks a lot :D

But remember that FOR variables are case sensitive.

Aacini
Expert
Posts: 1914
Joined: 06 Dec 2011 22:15
Location: México City, México
Contact:

Re: Weird arithmetic error in a simple script

#5 Post by Aacini » 28 Oct 2015 15:48

Lamcourt wrote:L stands for Large and l stands for lentgh



The unmeasurable question: if you want that one variable stands for Large and the other one for length, why don't you name them "Large" and "length"? Variable names may be many characters long. Please, do not ask how many characters a variable name can have! :shock:

Antonio

Post Reply