|
Answer» Hi, I have the following code: @echo off setlocal enabledelayedexpansion echo your letter is (in dutch: number = cijfer and letter = letter) set /p letter= if '%letter%'=='a' set cijfer=1 if '%letter%'=='b' set cijfer=2 if '%letter%'=='c' set cijfer=3 if '%letter%'=='d' set cijfer=4 if '%letter%'=='e' set cijfer=5 if '%letter%'=='F' set cijfer=6 if '%letter%'=='e' set cijfer=7 if '%letter%'=='f' set cijfer=8 if '%letter%'=='g' set cijfer=9 if '%letter%'=='h' set cijfer=10 if '%letter%'=='i' set cijfer=11 if '%letter%'=='j' set cijfer=12 if '%letter%'=='k' set cijfer=13 if '%letter%'=='l' set cijfer=14 if '%letter%'=='m' set cijfer=15 if '%letter%'=='N' set cijfer=16 if '%letter%'=='o' set cijfer=17 if '%letter%'=='p' set cijfer=18 if '%letter%'=='q' set cijfer=19 if '%letter%'=='r' set cijfer=20 if '%letter%'=='s' set cijfer=21 if '%letter%'=='t' set cijfer=22 if '%letter%'=='u' set cijfer=23 if '%letter%'=='v' set cijfer=24 if '%letter%'=='w' set cijfer=25 if '%letter%'=='x' set cijfer=26 if '%letter%'=='y' set cijfer=27 if '%letter%'=='z' set cijfer=28 set wachtwoordcijfer=%cijfer%+60
echo %wachtwoordcijfer% pause
the problem is: if I run this code set wachtwoordcijfer=%cijfer%+60 and echo it: i just get echoeed:'28+60' and STEAD of '88', how do I make that batch calculates the number?Try:
set /a wachtwoordcijfer=%cijfer%+60The Dutch alphabet must be hard to learn in school... 28 letters, with 'e' and 'f' appearing twice!
Code: [Select]if '%letter%'=='e' set cijfer=5 if '%letter%'=='f' set cijfer=6 if '%letter%'=='e' set cijfer=7 if '%letter%'=='f' set cijfer=8
Surprised you didn't spot that, Dudeoxide.
Blackberry, you should either tell your users to always use lowercase letters. or repeat each letter like this
if '%letter%'=='e' set cijfer=5 if '%letter%'=='E' set cijfer=5
Are there really 2 'e's and 2 'f's in the Netherlands? I know you have strange quote marks...
Why ADD 60 at the end? Just start at a=61
This is more compact if you don't need to test for case
Code: [Select]@echo off SETLOCAL ENABLEDELAYEDEXPANSION set /p letter=Enter character? set /a number=61 for %%L in (a b 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 "%letter%"=="%%L" set wachtwoordcijfer=!number! set /a number=!number!+1 ) echo %wachtwoordcijfer% Quote from: Dias de verano on May 25, 2008, 01:16:08 PM The Dutch alphabet must be hard to learn in school... 28 letters, with 'e' and 'f' appearing twice!
LOOOOL, firstly, we indeed have strange quotes, but this has nothing the do with the letters in the alfabet :-). And flamish = dutch (more or less) so don't think if anyone says that he speaks flamish and dutch, that he speaks two languages ;-). Secondly, I typed that really fast, so indeed I made an error, LOL. And last, thanks for your more compacted version, and also carbon thanks for your help. Much appreciated :-)
|