Convertir un Nombre en Lettre‎ [ FR ]

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Message
Author
alid0381
Posts: 28
Joined: 09 May 2012 10:37

Re: Convertir un Nombre en Lettre‎ [ FR ]

#16 Post by alid0381 » 30 Apr 2013 08:15

everybody

Thanks for your help me :wink:

with maturity

alid0381
Posts: 28
Joined: 09 May 2012 10:37

Re: Convertir un Nombre en Lettre‎ [ FR ]

#17 Post by alid0381 » 02 May 2013 05:10

He
Aacini || trebor68 || foxidrive || Endoro :arrow:

Your help has been invaluable to me.:arrow:
I sincerely,
Thank you so much.

Bilou_Gateux
Posts: 2
Joined: 04 May 2013 16:14

Re: Convertir un Nombre en Lettre‎ [ FR ]

#18 Post by Bilou_Gateux » 04 May 2013 16:47

@trebor68

Incredible script.
Just noticed rules below aren't applied in your batch

numbers 100 to 999
xy is a number of 1 up to 99
between the hundred and other number is one space

1xy = cent <space> xy
2xy = deux cents <space> xy
up to
9xy = neuf cents <space> xy

numbers 1000 to 999999
1000 = mille

1,yyy = mille yyy
xxx,yyy = xxx mille yyy


script.cmd 1100123
output
Un million un cent mille un cent vingt-trois


region=FR should output
Un million cent mille cent vingt-trois


and some other special rules in French
http://www.francaisfacile.com/exercices/exercice-francais-2/exercice-francais-39107.php

script.cmd 203
output
Deux cents trois


FR language should output
Deux cent trois


We do NOT add un (one) before cent (hundred)
in order to understand:
line 94 comment in your script
rem if %digit1% equ 1 (set words3=un cent) else set words3=!word[%digit1%]! cents

is FALSE

Code: Select all

rem if %digit1% equ 1 (set words3=cent) else set words3=!word[%digit1%]! cents

and the code should be corrected according to this rule.

http://www.daskoo.org/48-les-nombres.cours
Example:
Exemple :
I have a hundred books.
J'ai cent/une centaine de livres.
I have one hundred books.
J'ai cent livres.


It may be hard to take care of all French language strange rules but hope you will find the correct code!

trebor68
Posts: 146
Joined: 01 Jul 2011 08:47

Re: Convertir un Nombre en Lettre‎ [ FR ]

#19 Post by trebor68 » 10 May 2013 01:35

Thanks for your infos.

The following batch file, these errors have been corrected.

I apologize for this error.

The information for the batch file I've found through a web search.
If not all rules have been followed, please give me a reply. I need the specified parameters including numbers and a source of the rules for the correction.

This batch file convert a number to equivalent words in English, French, Spanish, Italian, Portuguese and German language.

It is possible that not all characters are displayed correctly.
My computer uses the Windows code page 1252 for the display in the Windows environment.
In the CMD window, the computer uses the DOS code page 850

At the end of the batch file there is a convertibility block for proper display in code page 850 The characters are also in code page 437 in the same place, but the two characters with the tilde (Portuguese language) can not be displayed.

Here short infos for the batch.

Code: Select all

Predefined parameters if these are not specified.
Parameter "/country" is specified.

country   scale    noMilliard      delimeter

  ENG     short       ----           ","       equivalent "/country=US"

  FR      long    not specified      " "
 FR_BE    long    not specified      "."       other words for 70 and 90
 FR_CH    long    not specified      "'"       other words for 70, 80 and 90

  ESP     long      specified        " "

  ITA     long      specified        "."

  POR     long      specified        " "       "/noMilliard" is specified automatically
POR_BRA   short       ----           " "       other words for 15, 17, 19, billion ...

  GER     long    not specified      "."       "/noMilliard" is ignored


Code: Select all

@echo off
setlocal EnableExtensions EnableDelayedExpansion

rem Convert a number to equivalent words in English, French, Spanish, Italian, Portuguese and German language
rem Basic batch file from Antonio Perez Ayala
rem Changes from Robert Staatz

rem Predefined variable "country" if they have not been specified as parameters.
set country=US
set "screenfile="

if "%1" equ "/?" (
   echo.
   echo    %0 [/country=yyy] [/scale=short^|long] [/noMilliard] [/file] xxx
   echo.
   echo    /country=yyy  Select a language or a language region.
   echo                  Possible values are: ENG, US, FR, FR_BE, FR_CH,
   echo                  ESP, ITA, POR, POR_BRA, GER
   echo.
   echo       /scale     short - use only million, billion, trillion, ...
   echo                  long  - use million, milliard, billion, billiard, ...
   echo.
   echo    /noMilliard   It does not use words like milliard, billiard, ...
   echo                  one milliard is thousand millions, ...
   echo.
   echo       /file      Use for correct spelling in a file.
   echo.
   echo    /delimeter=z  The delimeter is used to divide a number in three digits blocks.
   echo                  Put the character in double quotation marks.
   echo.
   echo       xxx        Number that is to be converted into words.
   echo                  This value is always the last parameter.
   echo.
   goto :eof
)

rem Use "/scale=short" or "/scale=long" as a parameter to change the predefined type.
rem Use "/noMilliard" as a parameter when "thousand million" is intended to be used.
rem Use "/FILE" as a parameter for correct spelling in a file.
rem Use "/delimeter" to change the preselected number delimeter.
:again
if /i "%1" equ "/country" (set country=%2) & shift & shift & goto :again
if /i "%1" equ "/scale" (set para_scale=%2) & shift & shift & goto :again
if /i "%1" equ "/noMilliard" (set para_noMilliard=1) & shift & goto :again
if /i "%1" equ "/file" (set screenfile=FILE) & shift & goto :again
if /i "%1" equ "/delimeter" (set para_delimeter=%~2) & shift & shift & goto :again

call :PreDefinated_%country%
if /i "%scale%%noMilliard%" equ "short1" set "noMilliard=0"
if defined para_delimeter set NumDelimiter=%para_delimeter%

if "%~1" neq "" (set number=%~1) else set number=0

rem Divide the number in blocks of 3 digits each
set blocks=-1
:nextBlock
   set /A blocks+=1
   set block[%blocks%]=%number:~-3%
   set number=%number:~0,-3%
if defined number goto nextBlock

rem Show the number as point-separated 3-digits blocks
set result=
for /L %%i in (%blocks%,-1,0) do (
   set result=!result!!block[%%i]!%NumDelimiter%
)
:: echo %result:~0,-1%
set completenumber=%result:~0,-1%

rem Convert the number to words
set result=00!block[%blocks%]!
set block[%blocks%]=%result:~-3%
set checkmio=0
set result=
for /L %%i in (%blocks%,-1,0) do (
   call :ConvertBlock_%country% %%i

   set helpblock3=!block3[%%i]!

   rem Convert 1 milliard = 1000 million etc, but only when parameter "/noMilliard" is used
   rem Convert:    xxx milliard yyy million ==> xxx thousand yyy million
   set /a helpnum="noMilliard * (%%i & 1) * ~((%%i - 2)>>31)"
   if !helpnum! equ -1 set helpblock3=!block3[1]!
   rem Convert from "one thousand million" to "thousand million"
   if %onethousand%!helpnum!!block[%%i]! equ 0-1001 (set "result=!result!!helpblock3!") & set "words3="
   rem Determine if the "million" has yet to be specified. ## xxx millard ==> xxx thousand million
   if !block[%%i]! equ 000 (set /a checkmio*=2) else set /a checkmio=2*checkmio+1
   set /a hnum="^!(%%i & 1) * (checkmio & 3)"

   if defined words3 set "resultblock=!words3!!helpblock3!"

   rem Generates the plural forms of a million and a milliard etc in different languages.
   rem Example in German for million : "1 Million" and "2 Millionen"    ( Mio1=llion and Mio2=llionen )
   rem Example in German for milliard: "1 Milliarde" and "2 Milliarden" ( Mrd1=lliarde and Mio2=lliairden )
   if !block[%%i]! neq 001 set resultblock=!resultblock:%Mio1%=%Mio2%!
   if !block[%%i]! neq 001 set resultblock=!resultblock:%Mrd1%=%Mrd2%!

   rem In Italian is also a separate plural form for thousand:   mille  ==>  mila
   if /i %country% equ ITA if !block[%%i]! neq 001 set resultblock=!resultblock:mille=mila!

   rem Only numbers 1000 to 1999 convert from "one thousand" to "thousand"
   if %onethousand%_!block[%%i]!_%%i equ 0_001_1 set "resultblock=!helpblock3!"

   if defined words3 set result=!result!!resultblock!

   rem Set "million" ... when the word is still missing: xxx milliard 000 million  ==>  xxx thousand million
   if %%i geq 2 if !noMilliard!_!hnum! equ 1_2 set "result=!result!!block3[%%i]:%Mio1%=%Mio2%!"
)
if not defined result set "result=!word[0]!"

rem Removes a space at the beginning. Removes a space if this is duplicated.
if "%result:~0,1%" equ " " set result=%result:~1%
set result=%result:  = %

rem Capitalize the first word
set firstLetter=%result:~0,1%
for %%a 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 set firstLetter=!firstLetter:%%a=%%a!
set result=%firstLetter%%result:~1%

call :ConvertTo_CP850
:: echo %result%
echo  %completenumber%  -  %result%

goto :EOF



:PreDefinated_US
:PreDefinated_ENG
rem Define delimiter in numbers; long or short scale; no milliard value
(set "NumDelimiter=,") & (set scale=short) & set noMilliard=0
if defined para_scale set scale=%para_scale%
if defined para_noMilliard set noMilliard=%para_noMilliard%

rem value is 1 => "one thousand"; value is 0 => "thousand"
set onethousand=1

rem Singular and plural form for million and milliard
rem The sign "#" is here used as a dummy, so that no error occurs.
(set Mio1=#) & (set Mio2=#) & (set Mrd1=#) & set "Mrd2=#"

rem Define word for number 0
set word[0]=zero

rem Define words for numbers 1 to 20
set i=1
for %%a in (one    two    three    four     five    six     seven     eight    nine     ten
            eleven twelve thirteen fourteen fifteen sixteen seventeen eighteen nineteen twenty) do (
   set word[!i!]=%%a
   set /A i+=1
)

rem Define words for numbers 30 to 100 step 10
set i=30
for %%a in (thirty forty fifty sixty seventy eighty ninety hundred) do (
   set word[!i!]=%%a
   set /A i+=10
)

rem Define words for blocks of 3 digits by position
set i=1
if /i %scale% neq long (
   rem Short scales
   for %%a in (thousand million billion trillion quadrillion quintillion sextillion septillion octillion nonillion decillion) do (
      set "block3[!i!]= %%a "
      set /A i+=1
   )
) else (
   rem Long scale
   for %%a in (thousand million milliard billion billiard trillion trilliard quadrillion quadrilliard quintillion quintilliard) do (
      set "block3[!i!]= %%a "
      set /A i+=1
   )
)
exit/b

:ConvertBlock_US index
:ConvertBlock_ENG index
set digits3=!block[%1]!
set digit1=%digits3:~0,1%
if %digits3:~1,1% neq 0 (set digits23=%digits3:~1%) else set digits23=%digits3:~2%
set words3=
if %digit1% neq 0 (
   rem Convert hundreds
   set words3=!word[%digit1%]! !word[100]!
)
if %digits23% neq 0 (
   rem Convert tens and units
   if %digits23% geq 20 (
      rem Convert tens 90..20
      set words2=!word[%digits3:~1,1%0]!
      rem Convert the units, if any
      set "words1="
      if %digits3:~2% neq 0 set words1=-!word[%digits3:~2%]!

      set words3=%words3%!words2!!words1!
   ) else (
      rem Convert tens/units 19..1
      set words1=!word[%digits23%]!

      set words3=%words3%!words1!
   )
   set "words3=!words3!"
)
exit /B



:PreDefinated_FR
:PreDefinated_FR_BE
:PreDefinated_FR_CH
rem Define delimiter in numbers; long or short scale; no milliard value
if /i %country% equ FR set "NumDelimiter= "
if /i %country% equ FR_BE set "NumDelimiter=."
if /i %country% equ FR_CH set "NumDelimiter='"
(set scale=long) & set noMilliard=0
if defined para_scale set scale=%para_scale%
if defined para_noMilliard set noMilliard=%para_noMilliard%

rem value is 1 => "one thousand"; value is 0 => "thousand"
set onethousand=0

rem Singular and plural form for million and milliard
(set Mio1=llion) & (set Mio2=llions) & (set Mrd1=lliard) & set Mrd2=lliards

rem Define word for number 0
set word[0]=zéro

rem Define words for numbers 1 to 20
set i=1
for %%a in (un   deux  trois  quatre   cinq   six   sept     huit     neuf     dix
            onze douze treize quatorze quinze seize dix-sept dix-huit dix-neuf vingt) do (
   set word[!i!]=%%a
   set /A i+=1
)

rem Define words for numbers 30 to 100 step 10
set i=30
for %%a in (trente quarante cinquante soixante soixante-dix quatre-vingt quatre-vingt-dix cent) do (
   set word[!i!]=%%a
   set /A i+=10
)
if /i %country% equ FR_BE (set word[70]=septante) & (set word[90]=nonante)
if /i %country% equ FR_CH (set word[70]=septante) & (set word[80]=huitante) & (set word[90]=nonante)

rem Define words for blocks of 3 digits by position (in France)
set i=1
if /i %scale% neq long (
   rem Short scales
   for %%a in (mille million billion trillion quadrillion quintillion  sextillion septillion octillion nonillion décillion) do (
     set "block3[!i!]= %%a "
     set /A i+=1
   )
) else (
   rem Long scale
   for %%a in (mille million milliard billion billiard trillion trilliard quadrillion quadrilliard quintillion quintrilliard) do (
      set "block3[!i!]= %%a "
      set /A i+=1
   )
)
exit /b

rem Source: http://fr.wikipedia.org/wiki/Nombres_en_fran%C3%A7ais
:ConvertBlock_FR index
:ConvertBlock_FR_BE index
:ConvertBlock_FR_CH index
set digits3=!block[%1]!
set digit1=%digits3:~0,1%
if %digits3:~1,1% neq 0 (set digits23=%digits3:~1%) else set digits23=%digits3:~2%
set words3=
rem This is needed for the suffix "-s" in x00 and x80 if the value does not follow "thousand".
rem 200, ..., 900 "xx cent" or "xx cents" also x80 "quatre-vingt" or "quatre-vingts"
set /a hnum2="^!(%1 & 1) * noMilliard + (1 - ^!(%1 - 1)) * ^!noMilliard"
if %digit1% neq 0 (
   rem Convert hundreds
   rem 100 to 199: cent ...   #   200: deux cents   #   201: deux cent un
   if %digit1% neq 1 (set words3=!word[%digit1%]! !word[100]!) else set words3=!word[100]!
   if %digit1% neq 1 if %digits23%_%hnum2% equ 0_1 set words3=!words3!s
   set "words3=!words3! "
)
if %digits23% neq 0 (
   rem Convert tens and units
   if %digits23% geq 20 (
      rem Convert tens 90..20
      set words2=!word[%digits3:~1,1%0]!
      set "words1="
      rem Convert the units, if any
      if %digits3:~2% neq 0 set words1=-!word[%digits3:~2%]!

      rem Only when the unit is 1 will change
      if /i %digits3:~2% equ 1 set words1= et un
      if /i %digits23%%country% equ 71FR    set words1= et onze
      if /i %digits23%%country% equ 91FR    set words1=-onze
      if /i %digits23%%country% equ 81FR    set words1=-un
      if /i %digits23%%country% equ 81FR_BE set words1=-un

      rem Only the 80 need the suffix "-s", but not when "mille", "million" ...
      if /i %hnum2%_%digits23%%country% equ 1_80FR    set words2=!words2!s
      if /i %hnum2%_%digits23%%country% equ 1_80FR_BE set words2=!words2!s

      rem Numbers 70+x are understand as 60+(10+x) and also numbers 90+x as 80+(10+x)
      set "hnum="
      if /i %digits3:~1,1%%country% equ 7FR (
         set /a hnum=digits23 - 60
         set words2=!word[60]!
      )
      if /i %digits3:~1,1%%country% equ 9FR (
         set /a hnum=digits23 - 80
         set words2=!word[80]!
      )
      if /i !hnum!%country% equ 10FR set words1=-!word[10]!
      if /i !hnum!%country% equ 12FR set words1=-!word[12]!
      if /i !hnum!%country% equ 13FR set words1=-!word[13]!
      if /i !hnum!%country% equ 14FR set words1=-!word[14]!
      if /i !hnum!%country% equ 15FR set words1=-!word[15]!
      if /i !hnum!%country% equ 16FR set words1=-!word[16]!
      if /i !hnum!%country% equ 17FR set words1=-!word[17]!
      if /i !hnum!%country% equ 18FR set words1=-!word[18]!
      if /i !hnum!%country% equ 19FR set words1=-!word[19]!

      set words3=%words3%!words2!!words1!
   ) else (
      rem Convert tens/units 19..1
      set words3=%words3%!word[%digits23%]!
   )
   set "words3=!words3!"
)
exit /B



rem Source: http://es.wikipedia.org/wiki/Anexo:Lista_de_n%C3%BAmeros
:PreDefinated_ESP
rem Define delimiter in numbers; long or short scale; no milliard value
(set "NumDelimiter= ") & (set scale=long) & set noMilliard=1
if defined para_scale (set scale=%para_scale%) & set noMilliard=0
if defined para_noMilliard set noMilliard=%para_noMilliard%

rem value is 1 => "one thousand"; value is 0 => "thousand"
set onethousand=0

rem Singular and plural form for million and milliard
(set Mio1=llón) & (set Mio2=llones) & (set Mrd1=llardo) & set Mrd2=llardos

rem Define word for number 0
set word[0]=cero

rem Define words for numbers 1 to 20
set i=1
for %%a in (uno  dos  tres  cuatro  cinco  seis          siete          ocho      nueve      diez
            once doce trece catorce quince "diez y seis" "diez y siete" dieciocho diecinueve veinte) do (
   set word[!i!]=%%~a
   set /A i+=1
)

rem Define words for numbers 30 to 100 step 10
set i=30
for %%a in (treinta cuarenta cincuenta sesenta setenta ochenta noventa ciento) do (
   set word[!i!]=%%a
   set /A i+=10
)

rem Define words for blocks of 3 digits by position
set i=1
if /i %scale% neq long (
   rem Short scales
   for %%a in (mil millón billón trillón cuatrillón quintillón sextillón septillón octillón nonillón decillón) do (
     set "block3[!i!]=%%a "
     set /A i+=1
   )
) else (
   rem Long scale
   for %%a in (mil millón millardo billón billardo trillón trillardo cuatrillón cuatrillardo quintillón quintillardo) do (
      set "block3[!i!]=%%a "
      set /A i+=1
   )
)
exit/b

:ConvertBlock_ESP index
set digits3=!block[%1]!
set digit1=%digits3:~0,1%
if %digits3:~1,1% neq 0 (set digits23=%digits3:~1%) else set digits23=%digits3:~2%
set words3=
if %digit1% neq 0 (
   rem Convert hundreds
   if %digit1% equ 1 (set words3=!word[100]!) else set words3=!word[%digit1%]!!word[100]!s
   if %digit1% equ 5 set words3=quinientos
   if %digit1% equ 7 set words3=sete!word[100]!s
   if %digit1% equ 9 set words3=nove!word[100]!s
   rem Only when number 100 whithout the tens/units
   if %digits3% equ 100 set words3=cien
   set "words3=!words3! "
)
if %digits23% neq 0 (
   rem Convert tens and units
   if %digits23% geq 20 (
      rem Convert tens 90..20
      set words2=!word[%digits3:~1,1%0]!
      rem Convert the units, if any
      set "words1="
      if %digits3:~2% neq 0 (
        set words1=!word[%digits3:~2%]!

        rem Change number 20 word "veinte" to "veinti" and when other tens change the unit
        if %digits3:~1,1% equ 2 (set words2=!word[20]:~0,-1!i) else set words1= y !words1!
      )
      if %digits23% equ 22 set words1=dós
      if %digits23% equ 23 set words1=trés
      if %digits23% equ 26 set words1=séis
      set words3=%words3%!words2!!words1!
   ) else (
      rem Convert tens/units 19..1
      set words3=%words3%!word[%digits23%]!

      if %1 gtr 1 if %digits3% equ 1 set words3=%words3%un
   )
   set "words3=!words3! "
)
exit /B



rem Source: http://en.wikibooks.org/wiki/Italian/Lesson4#Cardinal_numbers_up_to_1000
:PreDefinated_ITA
rem Define delimiter in numbers; long or short scale; no milliard value
(set "NumDelimiter=.") & (set scale=long) & set noMilliard=1
if defined para_scale (set scale=%para_scale%) & set noMilliard=0
if defined para_noMilliard set noMilliard=%para_noMilliard%

rem value is 1 => "one thousand"; value is 0 => "thousand"
set onethousand=0

rem Singular and plural form for million and milliard
(set Mio1=lione) & (set Mio2=lioni) & (set Mrd1=liardo) & set Mrd2=liardi

rem Define word for number 0
set word[0]=zero

rem Define words for numbers 1 to 20
set i=1
for %%a in (uno    due    tre     quattro     cinque   sei    sette       otto     nove       dieci
            undici dodici tredici quattordici quindici sedici diciassette diciotto diciannove venti) do (
   set word[!i!]=%%~a
   set /A i+=1
)

rem Define words for numbers 30 to 100 step 10
set i=30
for %%a in (trenta quaranta cinquanta sessanta settanta ottanta novanta cento) do (
   set word[!i!]=%%a
   set /A i+=10
)

rem Define words for blocks of 3 digits by position (short and long scale)
set i=1
if /i %scale% neq long (
   rem Short scale
   for %%a in (mille milione bilione trilione quadrilione quintilione sextilione septilione octilione nonilione decilione) do (
      set "block3[!i!]= %%a "
      set /A i+=1
   )
) else (
   rem Long scale
   for %%a in (mille milione miliardo bilione biliardo trilione triliardo quadrilione quadriliardo quintilione quintiliardo) do (
      set "block3[!i!]= %%a "
      set /A i+=1
   )
)
set block3[1]=!block3[1]:~1,-1!
exit/b

:ConvertBlock_ITA index
set digits3=!block[%1]!
set digit1=%digits3:~0,1%
if %digits3:~1,1% neq 0 (set digits23=%digits3:~1%) else set digits23=%digits3:~2%
set words3=
if %digit1% neq 0 (
   rem Convert hundreds
   if %digit1% equ 1 (set words3=!word[100]!) else set words3=!word[%digit1%]!!word[100]!

   rem 18x, 28x, ... 98x: xxx centoottanta  ==>  xxx centottanta    # Removes the last letter of "cento".
   rem 108, 208, ... 908: xxx centootto     ==>  xxx centotto       # Removes the last letter of "cento".
   if %digits3:~1,1% equ 8 set words3=!words3:~0,-1!
   if %digits23% equ 8 set words3=!words3:~0,-1!
)
if %digits23% neq 0 (
   rem Convert tens and units
   if %digits23% geq 20 (
      rem Convert tens 90..20
      set words2=!word[%digits3:~1,1%0]!
      rem Convert the units, if any
      set "words1="
      if %digits3:~2% neq 0 (
        set words1=!word[%digits3:~2%]!
        if %digits3:~2% equ 3 set words1=tré
        rem Changes the tens if the unit are 1 or 8
        if %digits23:~-1,1% equ 1 set words2=!words2:~0,-1!
        if %digits23:~-1,1% equ 8 set words2=!words2:~0,-1!
      )
      set words3=%words3%!words2!!words1!
   ) else (
      rem Convert tens/units 19..1
      set words3=%words3%!word[%digits23%]!

      if %1 gtr 1 if %digits3% equ 1 set words3=%words3%un
   )
   set "words3=!words3!"
)
exit /B



rem Source: http://de.wikibooks.org/wiki/Portugiesisch:_Zahlen
:PreDefinated_POR
:PreDefinated_POR_BRA
rem Define delimiter in numbers; long or short scale; no milliard value. Don't change noMilliard value.
set "NumDelimiter= "
if /i %country% equ POR (set scale=long) & set noMilliard=1
if /i %country% equ POR_BRA (set scale=short) & set noMilliard=0
if defined para_scale set scale=%para_scale%

rem value is 1 => "one thousand"; value is 0 => "thousand"
set onethousand=0

rem Singular and plural form for million and milliard
(set Mio1=ão) & (set Mio2=ões) & (set Mrd1=ão) & set Mrd2=ões

rem Define word for number 0
set word[0]=zero

rem Define words for numbers 1 to 20
set i=1
for %%a in (um   dois três  quatro  cinco  seis      sete      oito    nove     dez
            onze doze treze catorze quinze dezasseis dezassete dezoito dezanove vinte) do (
   set word[!i!]=%%a
   set /A i+=1
)

rem Define words for numbers 30 to 100 step 10
set i=30
for %%a in (trinta quarenta cinquenta sessenta setenta oitenta noventa cento) do (
   set word[!i!]=%%a
   set /A i+=10
)

rem Define words for blocks of 3 digits by position
rem In the Portuguese language there is no word for "milliard". The words in long scale are used for compatibility.
set i=1
if /i %scale% neq long (
   rem Short scales
   for %%a in (mil milhão bilião trilião quatrilião quintilião sextilião septilião octilião nonilião decilião) do (
     set "block3[!i!]=%%a "
     set /A i+=1
   )
) else (
   rem Long scale
   for %%a in (mil milhão milhão bilião bilião trilião trilião quatrilião quatrilião quintilião quintilião) do (
      set "block3[!i!]=%%a "
      set /A i+=1
   )
)
rem Changes the words of European Portuguese to Brazilian Portuguese words.
if /i %country% equ POR_BRA for /l %%a in (3, 1, 11) do set "block3[%%a]=!block3[%%a]:ião=hão!"
if /i %country% equ POR_BRA (set word[16]=dezesseis) & (set word[17]=dezessete) & set word[19]=dezenove
exit/b

:ConvertBlock_POR index
:ConvertBlock_POR_BRA index
set digits3=!block[%1]!
set digit1=%digits3:~0,1%
if %digits3:~1,1% neq 0 (set digits23=%digits3:~1%) else set digits23=%digits3:~2%
set words3=
if %digit1% neq 0 (
   rem Convert hundreds
   if %digit1% equ 1 (set words3=!word[100]!) else set words3=!word[%digit1%]!!word[100]!s
   if %digit1% equ 2 set words3=duzentos
   if %digit1% equ 3 set words3=trezentos
   if %digit1% equ 5 set words3=quinhentos
   rem Only when number 100 whithout the tens/units
   if %digits3% equ 100 set words3=cem
   if %blocks% neq %1 if %digits23% equ 0 set "words3=e !words3!"
   set "words3=!words3! "
)
if %digits23% neq 0 (
   rem Convert tens and units
   if %digits23% geq 20 (
      rem Convert tens 90..20
      set words2=!word[%digits3:~1,1%0]!
      if %blocks% neq %1 (set words2=e !words2!) else if %digits3% gtr 100 set words2=e !words2!

      rem Convert the units, if any
      set "words1="
      if %digits3:~2% neq 0 (
        set words1=e !word[%digits3:~2%]!
      )

      set words3=%words3% !words2! !words1!
   ) else (
      rem Convert tens/units 19..1
      set words1=!word[%digits23%]!
      if %blocks% neq %1 (set words1=e !words1!) else if %digits3% gtr 100 set words1=e !words1!
      set words3=%words3%!words1!
   )
   set "words3=!words3! "
)
exit /B



:PreDefinated_GER
rem Define delimiter in numbers; long or short scale; no milliard value. Don't change noMilliard value.
(set "NumDelimiter=.") & (set scale=long) & set noMilliard=0
if defined para_scale set scale=%para_scale%

rem value is 1 => "one thousand"; value is 0 => "thousand"
set onethousand=1

rem Singular and plural form for million and milliard
(set Mio1=llion) & (set Mio2=llionen) & (set Mrd1=lliarde) & set Mrd2=lliarden

rem Define word for number 0
set word[0]=null

rem Define words for numbers 1 to 20
set i=1
for %%a in (ein zwei  drei     vier     fünf     sechs    sieben   acht     neun     zehn
            elf zwölf dreizehn vierzehn fünfzehn sechzehn siebzehn achtzehn neunzehn zwanzig) do (
   set word[!i!]=%%a
   set /A i+=1
)

rem Define words for numbers 30 to 100 step 10
set i=30
for %%a in (dreißig vierzig fünfzig sechzig siebzig achtzig neunzig hundert) do (
   set word[!i!]=%%a
   set /A i+=10
)

rem Define words for blocks of 3 digits by position
set i=1
if /i %scale% neq long (
   rem Short scales
   for %%a in (tausend Million Billion Trillion Quadrillion Quentillion Sextillion Septillion Oktillion Nonillion Dezillion) do (
     set "block3[!i!]= %%a "
     set /A i+=1
   )
) else (
   rem Long scale
   for %%a in (tausend Million Milliarde Billion Billiarde Trillion Trilliarde Quadrillion Quadrilliarde Quintillion Quintilliarde) do (
      set "block3[!i!]= %%a "
      set /A i+=1
   )
)
set block3[1]=!block3[1]:~1,-1!
exit/b

:ConvertBlock_GER index
set digits3=!block[%1]!
set digit1=%digits3:~0,1%
if %digits3:~1,1% neq 0 (set digits23=%digits3:~1%) else set digits23=%digits3:~2%
set words3=
if %digit1% neq 0 (
   rem Convert hundreds
   set words3=!word[%digit1%]!!word[100]!
)
if %digits23% neq 0 (
   rem Convert tens and units
   if %digits23% geq 20 (
      rem Convert tens 90..20
      set words2=!word[%digits3:~1,1%0]!
      rem Convert the units, if any
      set "words1="
      if %digits3:~2% neq 0 set words1=!word[%digits3:~2%]!und

      set words3=%words3%!words1!!words2!
   ) else (
      rem Convert tens/units 19..1
      set words1=!word[%digits23%]!

      rem Only when number is 1
      if %1_%digits23% equ 0_1 set words1=eins
      if %1 geq 2 if %digits23% equ 1 set words1=eine

      set words3=%words3%!words1!
   )
   set "words3=!words3!"
)
exit /B



rem Convert letters from file (Windows CP1252) to letters at screen (DOS CP850 in CMD window).
rem The characters are listed here with the name, the ASCII code (CP850) and the Unicode
rem character (in hex numbers) and converted by using the following command.
rem The two characters with the tilde are not found in CP437. These are used in the Portuguese language.
:ConvertTo_CP850
   rem LATIN SMALL LETTER O WITH DIAERESIS   Alt+148      \u00F6  ==>  \u201D
   set result=%result:ö=”%
   rem LATIN SMALL LETTER U WITH DIAERESIS   Alt+129      \u00FC  ==>  \u0081
   set result=%result:ü=%
   rem LATIN SMALL LETTER SHARP S      Alt+225      \u00DF  ==>  \u00E1
   set result=%result:ß=á%
   rem LATIN SMALL LETTER E WITH ACUTE      Alt+130      \u00E9  ==>  \u201A
   set result=%result:é=‚%
   rem LATIN SMALL LETTER O WITH ACUTE      Alt+162      \u00F3  ==>  \u00A2
   set result=%result:ó=¢%
   rem LATIN SMALL LETTER E WITH CIRCUMFLEX   Alt+136      \u00EA  ==>  \u02C6
   set result=%result:ê=ˆ%
   rem LATIN SMALL LETTER A WITH TILDE      Alt+198      \u00E3  ==>  \u00C6
   set result=%result:ã=Æ%
   rem LATIN SMALL LETTER O WITH TILDE      Alt+228      \u00F5  ==>  \u00E4
   set result=%result:õ=ä%
exit /b

Bilou_Gateux
Posts: 2
Joined: 04 May 2013 16:14

Re: Convertir un Nombre en Lettre‎ [ FR ]

#20 Post by Bilou_Gateux » 19 May 2013 04:22

There's no need to apologize.

Despite the growth in the use of banks cards, France still retains an affinity for the cheque book. Indeed, over half the cheques issued in Europe come from France! Only in the last couple of years have card transactions exceeded payment by cheque. You will still find cheques in common use, particularly in the countryside and amongst the elderly.


When writing a cheque, you have to specify the amount using numerals (in the box on the right hand side) as well as words (on the line that says “Pay”).
It is trouble to write the amount in text correctly. Not every native french speaker pay attention on writing the amount so no mistake is made.

Ecrire un nombre en lettres
rules were revised regarding the use of hypen (trait d'union or tiret in French).
kids born after the 90's may use new rules but I seriously doubt it.
The effect of text messages and SMS language on writing...

If there are others rules that we're not up on, I'll let you know.

The new script behaves as expected.

alid0381
Posts: 28
Joined: 09 May 2012 10:37

Re: Convertir un Nombre en Lettre‎ [ FR ]

#21 Post by alid0381 » 27 May 2013 06:52

He
Aacini || trebor68 || foxidrive || Endoro and Bilou_Gateux:arrow:

Your help has been invaluable to me.:arrow:
I sincerely,
Thank you so much.
this is may code :

Code: Select all

@echo off
setlocal EnableDelayedExpansion
:AAA
color 1e
cls

set /p Nbr=Tapez Le Nbr :                                 
cls
echo.
echo  Le Nbr: %Nbr:~-18,-15% %Nbr:~-15,-12% %Nbr:~-12,-9% %Nbr:~-9,-6% %Nbr:~-6,-3% %Nbr:~-3%
echo.
:N
REM Define words for Nbrs 1 to 16 step 1
set i=1
for %%a in (Une Deux Trois Quatre Cinque Six Sept Huit Neuf Dix Onze Douze Treize Quatorze Quanze Seize) do (
   set word[!i!]=%%a
   set /A i+=1
)

REM Define words for Nbrs 17 to 19 step 1

for %%a in (7 8 9) do (
   set word[1%%a]=Dix !word[%%a]!
)

REM Define words for Nbrs 20 to 60 step 10
set i=20
for %%a in (vingt Trent Quarante Cinquante Soixante) do (
   set word[!i!]=%%a
   set /A i+=10
)
REM Define words for Nbrs 80
set word[80]=Quatre vingt

REM Define words for Nbrs 100
set word[100]=Cent

REM Define words for blocks of 3 digits by position (in US and Canada)
set i=1
for %%a in (Mille million Milliarde Billion Billiarde Trillion Trilliarde) do (
   set "block3[!i!]=%%a "
   set /A i+=1
)

if "%Nbr%" neq "" (set Nbr=%Nbr%) else set Nbr=0

REM Divide the Nbr in blocks of 3 digits each
set blocks=-1
:nextBlock
   set /A blocks+=1
   set block[%blocks%]=%Nbr:~-3%
   set Nbr=%Nbr:~,-3%
if defined Nbr goto nextBlock

REM Show the Nbr as comma-separated 3-digits blocks
set result=
for /L %%i in (%blocks%,-1,0) do (
   set result=!result!!block[%%i]!
)
cls
echo.
echo.
echo          %result:~0,-1%
REM Convert the Nbr to words
set result=00!block[%blocks%]!
set block[%blocks%]=%result:~-3%
set result=
for /L %%i in (%blocks%,-1,0) do (
   call :ConvertBlock %%i
   if defined words3 set "result=!result!!words3!!block3[%%i]!"
)
if not defined result set "result=Zero "

REM Capitalize the first word
set firstLetter=%result:~,1%
for %%a 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 set firstLetter=!firstLetter:%%a=%%a!
set result=%firstLetter%%result:~1,-1%
color a
echo.
echo.
echo.
echo                 %result%
echo.
pause>nul
goto AAA
goto :EOF

:ConvertBlock index
set digits3=!block[%1]!
set digit1=%digits3:~,1%
if %digits3:~1,1% neq 0 (set digits23=%digits3:~1%) else set digits23=%digits3:~2%
set words3=
if %digit1% neq 0 (
if %digit1% equ 1 (set words3=Cent ) else set words3=!word[%digit1%]! Cents
)
if %digits23% neq 0 (
REM Convert tens and units
if %digits23% geq 20 (
REM Convert tens 90..20
set words3=%words3% !word[%digits3:~1,1%0]!
REM Convert the units, if any
if %digits23% leq 69 (
if %digits3:~2% neq 0 (
if %digits3:~2% neq 1 (
set words3=!words3! !word[%digits3:~2%]!
) else (
set words3=%words3%!word[%digits3:~1,1%0]! Et Un
)) else (
set words3=%words3%!word[%digits23%]!
)) else (
if %digits3:~1,1% equ 8 (
if %digits3:~2% neq 0 (
if %digits3:~2% neq 1 ( set words3=!words3! Quatre vingt !word[%digits3:~2%]!
) else (
set words3=%words3%Quatre vingt Et Un
)) else (
set words3=%words3%!word[%digits23%]!
))
if %digits3:~1,1% equ 7 (
if %digits3:~2% neq 0 (
if %digits3:~2% neq 1 (
set words3=%words3% soixante !word[1%digits3:~2%]!
) else (
set words3=%words3%soixante Et Onze
)) else (
set words3=%words3%Soixante Dix
))
if %digits3:~1,1% equ 9 (
if %digits3:~2% neq 0 (
if %digits3:~2% neq 1 (
set words3=%words3% Quatre vingt !word[1%digits3:~2%]!
) else (
set words3=%words3%Quatre vingt Et Onze
)) else (
set words3=%words3%Quatre vingt Dix
)))
) else (
REM Convert tens/units 19..1
set words3=%words3%!word[%digits23%]!
)
set "words3=!words3! "
)
exit /B

trebor68
Posts: 146
Joined: 01 Jul 2011 08:47

Re: Convertir un Nombre en Lettre‎ [ FR ]

#22 Post by trebor68 » 29 May 2013 11:33

@alid0381
Your batch file is not running correct.

I have found some errors in your code and solved this.

But I'm not sure whether the line
echo Pour quitter, appuyez sur le bouton "Enter".
been correctly translated (by Google).
In English: To exit, press the button "Enter".

And now the code:

Code: Select all

@echo off
setlocal EnableExtensions EnableDelayedExpansion
color 1e

REM Define words for Nbrs 0 to 16 step 1
set i=0
for %%a in (Zero Une Deux Trois Quatre Cinque Six Sept Huit Neuf Dix Onze Douze Treize Quatorze Quanze Seize) do (
   set word[!i!]=%%a
   set /A i+=1
)

REM Define words for Nbrs 17 to 19 step 1
for %%a in (7 8 9) do (
   set word[1%%a]=Dix !word[%%a]!
)

REM Define words for Nbrs 20 to 60 step 10
set i=20
for %%a in (Vingt Trent Quarante Cinquante Soixante Soixante) do (
   set word[!i!]=%%~a
   set /A i+=10
)

REM Define words for Nbrs 80 and 100
set word[80]=Quatre vingt
set word[100]=Cent

REM Define words for blocks of 3 digits by position (long scale for France)
set i=1
for %%a in (Mille Million Milliard Billion Billiard Trillion Trilliard Quadrillion Quadrilliard Quintillion Quintrilliard) do (
   set "block3[!i!]=%%a "
   set /A i+=1
)

:AAA
cls
echo.
echo Pour quitter, appuyez sur le bouton "Enter".
echo.
set /p Nbr=Tapez Le Nbr :
if "%Nbr%" equ "" color a & goto :EOF
if %Nbr% equ 0 set result=word[0]

REM Divide the Nbr in blocks of 3 digits each
set blocks=-1
:nextBlock
   set /A blocks+=1
   set block[%blocks%]=%Nbr:~-3%
   set Nbr=%Nbr:~,-3%
if defined Nbr goto nextBlock

REM Show the Nbr as space-separated 3-digits blocks
set result=
for /L %%i in (%blocks%,-1,0) do (
   set "result=!result!!block[%%i]! "
)
echo.
echo.
echo   Le Nbr: %result:~0,-1%

REM Convert the Nbr to words
set result=00!block[%blocks%]!
set block[%blocks%]=%result:~-3%
set result=
for /L %%i in (%blocks%,-1,0) do (
   call :ConvertBlock %%i
   if defined words3 set "resultblock=!words3!!block3[%%i]!"
   if !block[%%i]! neq 001 if %%i geq 2 set "resultblock=!resultblock:~,-1!s "
   if defined words3 set result=!result!!resultblock!
)
if not defined result set "result=!word[0]!"

REM Capitalize the first word
REM set firstLetter=%result:~,1%
REM for %%a 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 set firstLetter=!firstLetter:%%a=%%a!
REM set result=%firstLetter%%result:~1,-1%
echo.
echo.
echo.
echo   %result%
echo.
pause>nul
goto AAA
goto :EOF

:ConvertBlock index
set digits3=!block[%1]!
set digit1=%digits3:~,1%
if %digits3:~1,1% neq 0 (set digits23=%digits3:~1%) else set digits23=%digits3:~2%
REM This is needed for the suffix "-s" in x00 and x80 if the value does not follow "thousand".
rem 200, ..., 900 "xx cent" or "xx cents" also x80 "quatre-vingt" or "quatre-vingts"
set /a hnum="^!(%1 - 1)"
set words3=
if %digit1% neq 0 (
   if %digit1% neq 1 (set words3=!word[%digit1%]! !word[100]!) else set words3=!word[100]!
   if %digit1% neq 1 if %digits23%_%hnum% equ 0_0 set words3=!words3!s
   set "words3=!words3! "
)
if %digits23% neq 0 (
   REM Convert tens and units
   if %digits23% geq 20 (
      REM Convert tens 90..20
      set words3=!words3!!word[%digits3:~1,1%0]!
      REM Convert the units, if any
      if %digits23% leq 69 (
         if %digits3:~2% neq 0 (
            if %digits3:~2% neq 1 (
               set words3=!words3! !word[%digits3:~2%]!
            ) else (
               set words3=!words3! Et Un
            )
         )
      ) else (
         REM Word for Nbr 80 is definated
         if %digits3:~1,1% equ 8 (
            if %digits3:~2% neq 0 (
               if %digits3:~2% neq 1 ( set words3=!words3! !word[%digits3:~2%]!
               ) else (
                  set words3=!words3! Et Un
               )
            ) else (
               if %hnum% equ 0 set words3=!words3!s
            )
         )
         if %digits3:~1,1% equ 7 (
         REM Word for Nbr 70 is definated as 60+10+x
            if %digits3:~2% neq 0 (
               if %digits3:~2% neq 1 (
                  set words3=!words3!!word[60]! !word[1%digits3:~2%]!
               ) else (
                  set words3=!words3!!word[60]! Et Onze
               )
            ) else (
               set words3=!words3!!word[60]! !word[10]!
            )
         )
         if %digits3:~1,1% equ 9 (
         REM Word for Nbr 90 is definated as 80+10+x
            if %digits3:~2% neq 0 (
               if %digits3:~2% neq 1 (
                  set words3=!words3!!word[80]! !word[1%digits3:~2%]!
               ) else (
                  set words3=!words3!!word[80]! Et Onze
               )
            ) else (
               set words3=!words3!!word[80]! !word[10]!
            )
         )
      )
   ) else (
      REM Convert tens/units 19..1
      set words3=!words3!!word[%digits23%]!
   )
   set "words3=!words3! "
)
exit /B

alid0381
Posts: 28
Joined: 09 May 2012 10:37

Re: Convertir un Nombre en Lettre‎ [ FR ]

#23 Post by alid0381 » 05 Jun 2013 09:18

trebor68;
Thanks for your postings


But there's another error 8) now when I did a test I see:
1 981 :
Une mille neuf cent quatre-vingt-un :P
instead of:
Mille neuf cent quatre-vingt-un 8)

I think the solution is : :D
if "%result:~,9%"=="Une Mille" set result=%result:~4%

Code: Select all

@echo off
setlocal EnableExtensions EnableDelayedExpansion
color 1e

REM Define words for Nbrs 0 to 16 step 1
set i=0
for %%a in (Zero Une Deux Trois Quatre Cinque Six Sept Huit Neuf Dix Onze Douze Treize Quatorze Quanze Seize) do (
   set word[!i!]=%%a
   set /A i+=1
)

REM Define words for Nbrs 17 to 19 step 1
for %%a in (7 8 9) do (
   set word[1%%a]=Dix !word[%%a]!
)

REM Define words for Nbrs 20 to 60 step 10
set i=20
for %%a in (Vingt Trent Quarante Cinquante Soixante Soixante) do (
   set word[!i!]=%%~a
   set /A i+=10
)

REM Define words for Nbrs 80 and 100
set word[80]=Quatre vingt
set word[100]=Cent

REM Define words for blocks of 3 digits by position (long scale for France)
set i=1
for %%a in (Mille Million Milliard Billion Billiard Trillion Trilliard Quadrillion Quadrilliard Quintillion Quintrilliard) do (
   set "block3[!i!]=%%a "
   set /A i+=1
)

:AAA
cls
echo.
echo Pour quitter, appuyez sur le bouton "Enter".
echo.
set /p Nbr=Tapez Le Nbr : 
if "%Nbr%" equ "" color a & goto :EOF
if %Nbr% equ 0 set result=word[0]

REM Divide the Nbr in blocks of 3 digits each
set blocks=-1
:nextBlock
   set /A blocks+=1
   set block[%blocks%]=%Nbr:~-3%
   set Nbr=%Nbr:~,-3%
if defined Nbr goto nextBlock

REM Show the Nbr as space-separated 3-digits blocks
set result=
for /L %%i in (%blocks%,-1,0) do (
   set "result=!result!!block[%%i]! "
)
echo.
echo.
echo   Le Nbr: %result:~0,-1%

REM Convert the Nbr to words
set result=00!block[%blocks%]!
set block[%blocks%]=%result:~-3%
set result=
for /L %%i in (%blocks%,-1,0) do (
   call :ConvertBlock %%i
   if defined words3 set "resultblock=!words3!!block3[%%i]!"
   if !block[%%i]! neq 001 if %%i geq 2 set "resultblock=!resultblock:~,-1!s "
   if defined words3 set result=!result!!resultblock!
)
if not defined result set "result=!word[0]!"

REM Capitalize the first word
REM set firstLetter=%result:~,1%
REM Correction
if "%result:~,9%"=="Une Mille" set result=%result:~4%
REM for %%a 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 set firstLetter=!firstLetter:%%a=%%a!
REM set result=%firstLetter%%result:~1,-1%
echo.
echo.
echo.
echo   %result%
echo.
pause>nul
goto AAA
goto :EOF

:ConvertBlock index
set digits3=!block[%1]!
set digit1=%digits3:~,1%
if %digits3:~1,1% neq 0 (set digits23=%digits3:~1%) else set digits23=%digits3:~2%
REM This is needed for the suffix "-s" in x00 and x80 if the value does not follow "thousand".
rem 200, ..., 900 "xx cent" or "xx cents" also x80 "quatre-vingt" or "quatre-vingts"
set /a hnum="^!(%1 - 1)"
set words3=
if %digit1% neq 0 (
   if %digit1% neq 1 (set words3=!word[%digit1%]! !word[100]!) else set words3=!word[100]!
   if %digit1% neq 1 if %digits23%_%hnum% equ 0_0 set words3=!words3!s
   set "words3=!words3! "
)
if %digits23% neq 0 (
   REM Convert tens and units
   if %digits23% geq 20 (
      REM Convert tens 90..20
      set words3=!words3!!word[%digits3:~1,1%0]!
      REM Convert the units, if any
      if %digits23% leq 69 (
         if %digits3:~2% neq 0 (
            if %digits3:~2% neq 1 (
               set words3=!words3! !word[%digits3:~2%]!
            ) else (
               set words3=!words3! Et Un
            )
         )
      ) else (
         REM Word for Nbr 80 is definated
         if %digits3:~1,1% equ 8 (
            if %digits3:~2% neq 0 (
               if %digits3:~2% neq 1 ( set words3=!words3! !word[%digits3:~2%]!
               ) else (
                  set words3=!words3! Et Un
               )
            ) else (
               if %hnum% equ 0 set words3=!words3!s
            )
         )
         if %digits3:~1,1% equ 7 (
         REM Word for Nbr 70 is definated as 60+10+x
            if %digits3:~2% neq 0 (
               if %digits3:~2% neq 1 (
                  set words3=!words3!!word[60]! !word[1%digits3:~2%]!
               ) else (
                  set words3=!words3!!word[60]! Et Onze
               )
            ) else (
               set words3=!words3!!word[60]! !word[10]!
            )
         )
         if %digits3:~1,1% equ 9 (
         REM Word for Nbr 90 is definated as 80+10+x
            if %digits3:~2% neq 0 (
               if %digits3:~2% neq 1 (
                  set words3=!words3!!word[80]! !word[1%digits3:~2%]!
               ) else (
                  set words3=!words3!!word[80]! Et Onze
               )
            ) else (
               set words3=!words3!!word[80]! !word[10]!
            )
         )
      )
   ) else (
      REM Convert tens/units 19..1
      set words3=!words3!!word[%digits23%]!
   )
   set "words3=!words3! "
)
exit /B


For example:

Code: Select all

Pour quitter, appuyez sur le bouton "Enter".
Tapez Le Nbr :  1981
     
    Le Nbr :  1 981


    Mille neuf cent quatre-vingt-un

trebor68
Posts: 146
Joined: 01 Jul 2011 08:47

Re: Convertir un Nombre en Lettre‎ [ FR ]

#24 Post by trebor68 » 09 Jun 2013 18:32

Please excuse me, I've forgotten the last time to test all combinations.

Find the following first code, and fill it with two rows. The result is the second following code.


Please change this code:

Code: Select all

....

REM Convert the Nbr to words
set result=00!block[%blocks%]!
set block[%blocks%]=%result:~-3%
set result=
for /L %%i in (%blocks%,-1,0) do (
   call :ConvertBlock %%i
   if defined words3 set "resultblock=!words3!!block3[%%i]!"
   if !block[%%i]! neq 001 if %%i geq 2 set "resultblock=!resultblock:~,-1!s "

   if defined words3 set result=!result!!resultblock!
)
if not defined result set "result=!word[0]!"

....



to this code:

Code: Select all

....

REM Convert the Nbr to words
set result=00!block[%blocks%]!
set block[%blocks%]=%result:~-3%
set result=
for /L %%i in (%blocks%,-1,0) do (
   call :ConvertBlock %%i
   if defined words3 set "resultblock=!words3!!block3[%%i]!"
   if !block[%%i]! neq 001 if %%i geq 2 set "resultblock=!resultblock:~,-1!s "


   rem Only numbers 1000 to 1999 convert from "one thousand" to "thousand"
   if !block[%%i]!_%%i equ 001_1 set "resultblock=!block3[%%i]!"


   if defined words3 set result=!result!!resultblock!
)
if not defined result set "result=!word[0]!"

....

alid0381
Posts: 28
Joined: 09 May 2012 10:37

Re: Convertir un Nombre en Lettre‎ [ FR ]

#25 Post by alid0381 » 20 Jun 2013 09:57

thanks, trebor68, I will do :)

Post Reply